diff --git a/test/component/DaughterTable.test.ts b/test/component/DaughterTable.test.ts index 50401cd..e901893 100644 --- a/test/component/DaughterTable.test.ts +++ b/test/component/DaughterTable.test.ts @@ -11,6 +11,7 @@ import { vuetify4Test } from '../extra/vuetify4Test'; import DaughterTable from '@/components/DaughterTable.vue'; import { createI18n, } from "vue-i18n"; import { selectInputByValue } from '../extra/selectBy'; +import { mockNuxtImport } from '@nuxt/test-utils/runtime'; // Overwrite the internalization plugin with empty one const i18n = createI18n({}); @@ -69,6 +70,27 @@ const daughter_twenteen = [{ const $fetchMock = vi.fn(); vi.stubGlobal('$fetch',$fetchMock); + +const { useMessageMock} = vi.hoisted(() => { + return { useMessageMock: vi.fn()} +}); + + +// Mock useMessage +const useMessageErrorMock = vi.fn(); +mockNuxtImport('useMessage', () => { + return useMessageMock; +}) + +useMessageMock.mockImplementation(() => { + return { + error: useMessageErrorMock, + success: vi.fn() + } +}); + + + /** * Check header of table * @param wrapper html wrapper @@ -359,5 +381,8 @@ describe('DaughterTable', () => { expect(tBody.findAll('input').length).toBe(0); checkCloseGroup(wrapper, daughter_one); checkCloseGroup(wrapper, daughter_twenteen); + expect(useMessageErrorMock).toHaveBeenCalled(); + expect(useMessageErrorMock). + toHaveBeenCalledWith('message.error.deleteDaughterFile'); }); }); \ No newline at end of file