Skip to content

Commit

Permalink
#48 all test for DaughterTable
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcellino-Palerme committed Jul 26, 2024
1 parent cf17f63 commit f98ba57
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/component/DaughterTable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({});
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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');
});
});

0 comments on commit f98ba57

Please sign in to comment.