feat: refs #7087 created CardSummary test

This commit is contained in:
PAU ROVIRA ROSALENY 2025-01-10 14:08:25 +01:00
parent c6a9c55ddc
commit bb6fae5d08
1 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,48 @@
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
import { createWrapper, axios } from 'app/test/vitest/helper';
import CardSummary from 'src/components/ui/CardSummary.vue';
describe('CardSummary', () => {
let vm;
let wrapper;
beforeAll(() => {
const mockApiResponse = {
data: {
data: [],
total: 0,
}
};
vi.spyOn(axios, 'get').mockResolvedValue(mockApiResponse);
wrapper = createWrapper(CardSummary, {
global: {
stubs: [
'arrayData',
'useArrayData',
],
mocks: {
validate: vi.fn(),
},
},
propsData: {
dataKey: 'cardSummaryKey',
url: 'cardSummaryUrl',
},
});
vm = wrapper.vm;
wrapper = wrapper.wrapper;
});
afterEach(() => {
vi.clearAllMocks();
});
it('should fetch data', async () => {
expect(wrapper.emitted('fetch'));
});
});