mirror of
https://github.com/directus/directus.git
synced 2026-02-08 20:15:13 -05:00
61 lines
1.1 KiB
TypeScript
61 lines
1.1 KiB
TypeScript
import { test, expect, beforeEach } from 'vitest';
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import VButton from './v-button.vue';
|
|
import { h } from 'vue';
|
|
import { generateRouter } from '@/__utils__/router';
|
|
import { Router } from 'vue-router';
|
|
import { GlobalMountOptions } from '@vue/test-utils/dist/types';
|
|
import { Focus } from '@/__utils__/focus';
|
|
|
|
let router: Router;
|
|
|
|
let global: GlobalMountOptions;
|
|
|
|
beforeEach(async () => {
|
|
router = generateRouter([
|
|
{
|
|
path: '/',
|
|
component: h('div', VButton),
|
|
},
|
|
{
|
|
path: '/test',
|
|
component: h('div', 'empty'),
|
|
},
|
|
]);
|
|
router.push('/');
|
|
await router.isReady();
|
|
|
|
global = {
|
|
stubs: ['v-progress-circular'],
|
|
directives: {
|
|
focus: Focus,
|
|
},
|
|
plugins: [router],
|
|
};
|
|
});
|
|
|
|
test('Mount component', () => {
|
|
expect(VButton).toBeTruthy();
|
|
|
|
const wrapper = mount(VButton, {
|
|
global,
|
|
});
|
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
});
|
|
|
|
// test('Click on link', async () => {
|
|
// const wrapper = mount(VButton, {
|
|
// props: {
|
|
// to: '/test'
|
|
// },
|
|
// global
|
|
// });
|
|
|
|
// await wrapper.get('a').trigger('click')
|
|
|
|
// expect(router.currentRoute.value.path).toBe('/test')
|
|
|
|
// });
|