From bb6fae5d087575a84418549cc75ed22ca8e01a23 Mon Sep 17 00:00:00 2001 From: provira Date: Fri, 10 Jan 2025 14:08:25 +0100 Subject: [PATCH] feat: refs #7087 created CardSummary test --- .../ui/__tests__/CardSummary.spec.js | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/components/ui/__tests__/CardSummary.spec.js diff --git a/src/components/ui/__tests__/CardSummary.spec.js b/src/components/ui/__tests__/CardSummary.spec.js new file mode 100644 index 000000000..4a32e92e5 --- /dev/null +++ b/src/components/ui/__tests__/CardSummary.spec.js @@ -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')); + }); + +}); \ No newline at end of file