This commit is contained in:
parent
ef8e77904d
commit
988c47677b
|
@ -2,36 +2,6 @@ import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vite
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||||
|
|
||||||
vi.mock('vue-router', () => ({
|
|
||||||
useRouter: () => ({
|
|
||||||
push: vi.fn( ),
|
|
||||||
currentRoute: {
|
|
||||||
value: {
|
|
||||||
params: {
|
|
||||||
id: 11,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
useRoute: () => ({
|
|
||||||
matched: [
|
|
||||||
{
|
|
||||||
path: '/',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/customer',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/customer/:id',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/customer/:id/basic-data',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
query: {},
|
|
||||||
params: {},
|
|
||||||
}),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('VnSearchBar', () => {
|
describe('VnSearchBar', () => {
|
||||||
let vm;
|
let vm;
|
||||||
|
@ -46,7 +16,20 @@ describe('VnSearchBar', () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
vm = wrapper.vm;
|
vm = wrapper.vm;
|
||||||
|
vm.route.matched = [
|
||||||
|
{
|
||||||
|
path: '/',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/customer',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/customer/:id',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/customer/:id/basic-data',
|
||||||
|
},
|
||||||
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|
|
@ -14,6 +14,25 @@ installQuasarPlugin({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const pinia = createTestingPinia({ createSpy: vi.fn, stubActions: false });
|
const pinia = createTestingPinia({ createSpy: vi.fn, stubActions: false });
|
||||||
|
const mockPush = vi.fn();
|
||||||
|
|
||||||
|
vi.mock('vue-router', () => ({
|
||||||
|
useRouter: () => ({
|
||||||
|
push: mockPush,
|
||||||
|
currentRoute: {
|
||||||
|
value: {
|
||||||
|
params: {
|
||||||
|
id: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
useRoute: () => ({
|
||||||
|
matched: [],
|
||||||
|
query: {},
|
||||||
|
params: {},
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
vi.mock('axios');
|
vi.mock('axios');
|
||||||
|
|
||||||
|
@ -55,7 +74,6 @@ export function createWrapper(component, options) {
|
||||||
mocks: {
|
mocks: {
|
||||||
t: (tKey) => tKey,
|
t: (tKey) => tKey,
|
||||||
$t: (tKey) => tKey,
|
$t: (tKey) => tKey,
|
||||||
customRouter: false
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue