test: refs #7073 add unit tests for VnDms component #1198
|
@ -1,4 +1,4 @@
|
|||
import { createWrapper, axios, flushPromises } from 'app/test/vitest/helper';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
import VnDms from 'src/components/common/VnDms.vue';
|
||||
|
||||
|
@ -115,16 +115,32 @@ describe('VnDms', () => {
|
|||
await vm.save();
|
||||
expect(postMock).toHaveBeenCalledWith(vm.getUrl(), expect.any(FormData), { params: expectedBody });
|
||||
expect(wrapper.emitted('onDataSaved')).toBeTruthy();
|
||||
//expect(emitMock).toHaveBeenCalledWith('onDataSaved', expectedBody, postResponseMock);
|
||||
});
|
||||
});
|
||||
|
||||
describe('defaultData', () => {
|
||||
it('should set default data correctly', async () => {
|
||||
await wrapper.setProps({ formInitialData: null });
|
||||
it('should set dms with formInitialData', async () => {
|
||||
const testData = {
|
||||
hasFile: false,
|
||||
hasFileAttached: false,
|
||||
reference: 'defaultData-test',
|
||||
warehouseFk: 2,
|
||||
companyFk: 3,
|
||||
dmsTypeFk: 2,
|
||||
description: 'This is a test description'
|
||||
}
|
||||
await wrapper.setProps({ formInitialData: testData });
|
||||
vm.defaultData();
|
||||
|
||||
expect(vm.dms.reference).toBe('123');
|
||||
expect(vm.dms).toEqual(testData);
|
||||
});
|
||||
|
||||
it('should add reference with "route.params.id" to dms if formInitialData is null', async () => {
|
||||
await wrapper.setProps({ formInitialData: null });
|
||||
vm.route.params.id= '111';
|
||||
vm.defaultData();
|
||||
|
||||
expect(vm.dms.reference).toBe('111');
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue