8389-testToMaster #1207
|
@ -2,15 +2,18 @@ import { createWrapper, axios } from 'app/test/vitest/helper';
|
|||
import EditForm from 'components/EditTableCellValueForm.vue';
|
||||
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
describe('EditForm', () => {
|
||||
const fieldA = 'fieldA';
|
||||
const fieldB = 'fieldB';
|
||||
|
||||
describe.only('EditForm', () => {
|
||||
let vm;
|
||||
const mockRows = [
|
||||
{ id: 1, itemFk: 101 },
|
||||
{ id: 2, itemFk: 102 },
|
||||
];
|
||||
const mockFieldsOptions = [
|
||||
{ label: 'Field A', field: 'fieldA', component: 'input', attrs: {} },
|
||||
{ label: 'Field B', field: 'fieldB', component: 'date', attrs: {} },
|
||||
{ label: 'Field A', field: fieldA, component: 'input', attrs: {} },
|
||||
{ label: 'Field B', field: fieldB, component: 'date', attrs: {} },
|
||||
];
|
||||
const editUrl = '/api/edit';
|
||||
|
||||
|
@ -31,7 +34,7 @@ describe('EditForm', () => {
|
|||
|
||||
describe('onSubmit()', () => {
|
||||
it('should call axios.post with the correct parameters in the payload', async () => {
|
||||
const selectedField = { field: 'fieldA', component: 'input', attrs: {} };
|
||||
const selectedField = { field: fieldA, component: 'input', attrs: {} };
|
||||
const newValue = 'Test Value';
|
||||
|
||||
vm.selectedField = selectedField;
|
||||
|
@ -42,12 +45,12 @@ describe('EditForm', () => {
|
|||
const payload = axios.post.mock.calls[0][1];
|
||||
|
||||
expect(axios.post).toHaveBeenCalledWith(editUrl, expect.any(Object));
|
||||
expect(payload.field).toEqual('fieldA');
|
||||
expect(payload.newValue).toEqual('Test Value');
|
||||
expect(payload.field).toEqual(fieldA);
|
||||
expect(payload.newValue).toEqual(newValue);
|
||||
|
||||
expect(payload.lines).toContainEqual(
|
||||
expect.objectContaining({ id: 1, itemFk: 101 })
|
||||
);
|
||||
expect(payload.lines).toEqual(expect.arrayContaining(mockRows));
|
||||
console.log('payload.lines', payload.lines);
|
||||
console.log('mockRows', expect.arrayContaining(mockRows));
|
||||
|
||||
expect(vm.isLoading).toEqual(false);
|
||||
});
|
Loading…
Reference in New Issue