resf #5673 test(claimDevelopment): front test
gitea/salix-front/pipeline/head There was a failure building this commit
Details
gitea/salix-front/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
a09b4ff548
commit
6260b7ed5e
|
@ -16,7 +16,7 @@ import ClaimLinesImport from './ClaimLinesImport.vue';
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
console.log(t);
|
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const arrayData = useArrayData('ClaimLines');
|
const arrayData = useArrayData('ClaimLines');
|
||||||
const store = arrayData.store;
|
const store = arrayData.store;
|
||||||
|
|
|
@ -20,7 +20,7 @@ const $props = defineProps({
|
||||||
});
|
});
|
||||||
const entityId = computed(() => $props.id || route.params.id);
|
const entityId = computed(() => $props.id || route.params.id);
|
||||||
|
|
||||||
let wagonTypes;
|
let wagonTypes = [];
|
||||||
let originalData = {};
|
let originalData = {};
|
||||||
const wagon = ref({});
|
const wagon = ref({});
|
||||||
const filteredWagonTypes = ref(wagonTypes);
|
const filteredWagonTypes = ref(wagonTypes);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||||
import CrudModel from 'components/CrudModel.vue';
|
import CrudModel from 'components/CrudModel.vue';
|
||||||
import { vi, afterEach, beforeAll, beforeEach, describe, expect, it } from 'vitest';
|
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||||
import { onMounted, ref } from 'vue';
|
|
||||||
|
|
||||||
describe.only('CrudModel', () => {
|
describe.only('CrudModel', () => {
|
||||||
let vm;
|
let vm;
|
||||||
|
@ -13,7 +12,7 @@ describe.only('CrudModel', () => {
|
||||||
'useState',
|
'useState',
|
||||||
'arrayData',
|
'arrayData',
|
||||||
'useStateStore',
|
'useStateStore',
|
||||||
'useValidator',
|
'vue-i18n',
|
||||||
],
|
],
|
||||||
mocks: {
|
mocks: {
|
||||||
fetch: vi.fn(),
|
fetch: vi.fn(),
|
||||||
|
@ -27,6 +26,7 @@ describe.only('CrudModel', () => {
|
||||||
autoLoad: true,
|
autoLoad: true,
|
||||||
},
|
},
|
||||||
dataKey: 'crudModelKey',
|
dataKey: 'crudModelKey',
|
||||||
|
model: 'crudModel',
|
||||||
url: 'crudModelUrl',
|
url: 'crudModelUrl',
|
||||||
},
|
},
|
||||||
attrs: {
|
attrs: {
|
||||||
|
@ -44,15 +44,14 @@ describe.only('CrudModel', () => {
|
||||||
|
|
||||||
describe('insert()', () => {
|
describe('insert()', () => {
|
||||||
it('should new element in list with index 0 if formData not has data', () => {
|
it('should new element in list with index 0 if formData not has data', () => {
|
||||||
// vi.spyOn(axios, 'get').mockResolvedValue({
|
vi.spyOn(axios, 'get').mockResolvedValue({
|
||||||
// data: [
|
data: [
|
||||||
// { id: 1, name: 'Tony Stark' },
|
{ id: 1, name: 'Tony Stark' },
|
||||||
// { id: 2, name: 'Jessica Jones' },
|
{ id: 2, name: 'Jessica Jones' },
|
||||||
// { id: 3, name: 'Bruce Wayne' },
|
{ id: 3, name: 'Bruce Wayne' },
|
||||||
// ],
|
],
|
||||||
// });
|
});
|
||||||
// vm.state.set('crudModel', []);
|
vm.state.set('crudModel', []);
|
||||||
vm.formData = ref([]);
|
|
||||||
|
|
||||||
vm.insert();
|
vm.insert();
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,6 @@ describe('ClaimLines', () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}).vm;
|
}).vm;
|
||||||
vi.mock('src/composables/useValidator', () => ({
|
|
||||||
fetch: () => vi.fn(),
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -7,9 +7,11 @@ describe('WagonCreate', () => {
|
||||||
const entityId = 1;
|
const entityId = 1;
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
vmEdit = createWrapper(WagonCreate, {propsData: {
|
vmEdit = createWrapper(WagonCreate, {
|
||||||
|
propsData: {
|
||||||
id: entityId,
|
id: entityId,
|
||||||
}}).vm;
|
},
|
||||||
|
}).vm;
|
||||||
vmCreate = createWrapper(WagonCreate).vm;
|
vmCreate = createWrapper(WagonCreate).vm;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -29,9 +31,7 @@ describe('WagonCreate', () => {
|
||||||
|
|
||||||
await vmCreate.onSubmit();
|
await vmCreate.onSubmit();
|
||||||
|
|
||||||
expect(axios.patch).toHaveBeenCalledWith(
|
expect(axios.patch).toHaveBeenCalledWith(`Wagons`, vmCreate.wagon);
|
||||||
`Wagons`, vmCreate.wagon
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update a wagon', async () => {
|
it('should update a wagon', async () => {
|
||||||
|
@ -46,9 +46,7 @@ describe('WagonCreate', () => {
|
||||||
|
|
||||||
await vmEdit.onSubmit();
|
await vmEdit.onSubmit();
|
||||||
|
|
||||||
expect(axios.patch).toHaveBeenCalledWith(
|
expect(axios.patch).toHaveBeenCalledWith(`Wagons`, vmEdit.wagon);
|
||||||
`Wagons`, vmEdit.wagon
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -88,16 +86,12 @@ describe('WagonCreate', () => {
|
||||||
|
|
||||||
describe('fetch()', () => {
|
describe('fetch()', () => {
|
||||||
it('should fetch data', async () => {
|
it('should fetch data', async () => {
|
||||||
vi.spyOn(axios, 'get').mockResolvedValue({ data: true });
|
vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
|
||||||
|
|
||||||
await vmEdit.fetch();
|
await vmEdit.fetch();
|
||||||
|
|
||||||
expect(axios.get).toHaveBeenCalledWith(
|
expect(axios.get).toHaveBeenCalledWith(`WagonTypes`);
|
||||||
`WagonTypes`
|
expect(axios.get).toHaveBeenCalledWith(`Wagons/${entityId}`);
|
||||||
);
|
|
||||||
expect(axios.get).toHaveBeenCalledWith(
|
|
||||||
`Wagons/${entityId}`
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { vi } from 'vitest';
|
||||||
import { i18n } from 'src/boot/i18n';
|
import { i18n } from 'src/boot/i18n';
|
||||||
import { Notify, Dialog } from 'quasar';
|
import { Notify, Dialog } from 'quasar';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import * as useValidator from 'src/composables/useValidator';
|
||||||
|
|
||||||
installQuasarPlugin({
|
installQuasarPlugin({
|
||||||
plugins: {
|
plugins: {
|
||||||
|
@ -34,6 +35,10 @@ vi.mock('vue-router', () => ({
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
vi.spyOn(useValidator, 'useValidator').mockImplementation(() => {
|
||||||
|
return { validate: vi.fn(), fetch: vi.fn() };
|
||||||
|
});
|
||||||
|
|
||||||
class FormDataMock {
|
class FormDataMock {
|
||||||
append() {
|
append() {
|
||||||
vi.fn();
|
vi.fn();
|
||||||
|
@ -79,7 +84,6 @@ export function createWrapper(component, options) {
|
||||||
mountOptions.global.plugins = defaultOptions.global.plugins;
|
mountOptions.global.plugins = defaultOptions.global.plugins;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(mountOptions);
|
|
||||||
|
|
||||||
const wrapper = mount(component, mountOptions);
|
const wrapper = mount(component, mountOptions);
|
||||||
const vm = wrapper.vm;
|
const vm = wrapper.vm;
|
||||||
|
|
Loading…
Reference in New Issue