test: refs #7073 add test to defaultData if formInitialData has value
gitea/salix-front/pipeline/pr-dev Build queued...
Details
gitea/salix-front/pipeline/pr-dev Build queued...
Details
This commit is contained in:
parent
b26d1f7945
commit
5b6ad1a7c0
|
@ -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 { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest';
|
||||||
import VnDms from 'src/components/common/VnDms.vue';
|
import VnDms from 'src/components/common/VnDms.vue';
|
||||||
|
|
||||||
|
@ -115,16 +115,32 @@ describe('VnDms', () => {
|
||||||
await vm.save();
|
await vm.save();
|
||||||
expect(postMock).toHaveBeenCalledWith(vm.getUrl(), expect.any(FormData), { params: expectedBody });
|
expect(postMock).toHaveBeenCalledWith(vm.getUrl(), expect.any(FormData), { params: expectedBody });
|
||||||
expect(wrapper.emitted('onDataSaved')).toBeTruthy();
|
expect(wrapper.emitted('onDataSaved')).toBeTruthy();
|
||||||
//expect(emitMock).toHaveBeenCalledWith('onDataSaved', expectedBody, postResponseMock);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('defaultData', () => {
|
describe('defaultData', () => {
|
||||||
it('should set default data correctly', async () => {
|
it('should set dms with formInitialData', async () => {
|
||||||
await wrapper.setProps({ formInitialData: null });
|
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();
|
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