mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 02:44:45 +00:00
37 lines
906 B
TypeScript
37 lines
906 B
TypeScript
import { defineComponent } from 'vue';
|
|
import { describe, it, expect } from 'vitest';
|
|
import { useSupported } from '.';
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
const ComponentStub = defineComponent({
|
|
props: {
|
|
location: {
|
|
type: String,
|
|
default: 'location',
|
|
},
|
|
},
|
|
setup(props) {
|
|
const isSupported = useSupported(() => props.location in globalThis);
|
|
|
|
return { isSupported };
|
|
},
|
|
template: `<div>{{ isSupported }}</div>`,
|
|
});
|
|
|
|
describe(useSupported, () => {
|
|
it('return whether the feature is supported', async () => {
|
|
const component = mount(ComponentStub);
|
|
|
|
expect(component.text()).toBe('true');
|
|
});
|
|
|
|
it('return whether the feature is not supported', async () => {
|
|
const component = mount(ComponentStub, {
|
|
props: {
|
|
location: 'unsupported',
|
|
},
|
|
});
|
|
|
|
expect(component.text()).toBe('false');
|
|
});
|
|
}); |