refs #6384 test: fix vitest
gitea/salix-front/pipeline/head This commit looks good Details

This commit is contained in:
Javier Segarra 2024-01-09 17:01:11 +01:00
parent ef8e77904d
commit 988c47677b
2 changed files with 33 additions and 32 deletions

View File

@ -2,36 +2,6 @@ import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vite
import { createWrapper, axios } from 'app/test/vitest/helper';
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', () => {
let vm;
@ -46,7 +16,20 @@ describe('VnSearchBar', () => {
},
});
vm = wrapper.vm;
vm.route.matched = [
{
path: '/',
},
{
path: '/customer',
},
{
path: '/customer/:id',
},
{
path: '/customer/:id/basic-data',
},
];
});
afterEach(() => {

View File

@ -14,6 +14,25 @@ installQuasarPlugin({
},
});
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');
@ -55,7 +74,6 @@ export function createWrapper(component, options) {
mocks: {
t: (tKey) => tKey,
$t: (tKey) => tKey,
customRouter: false
},
};