refs #5056 working on tests
gitea/salix-front/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alexandre Riera 2023-03-21 12:47:43 +01:00
parent 99672200d5
commit 42511dc5bd
5 changed files with 76 additions and 2 deletions

View File

@ -416,6 +416,7 @@ export default {
label: 'Label'
},
warnings: {
noData: 'No data available',
nameNotEmpty: 'Name can not be empty',
labelNotEmpty: 'Label can not be empty',
plateNotEmpty: 'Plate can not be empty',

View File

@ -415,6 +415,7 @@ export default {
label: 'Etiqueta',
},
warnings: {
noData: 'Sin datos disponibles',
nameNotEmpty: 'El nombre no puede estar vacío',
labelNotEmpty: 'La etiqueta no puede estar vacía',
plateNotEmpty: 'La matrícula no puede estar vacía',

View File

@ -320,7 +320,7 @@ function checkMaxHeight(pos) {
<q-dialog
v-model="colorPickerActive"
position="right"
no-backdrop-dismiss="false"
:no-backdrop-dismiss="false"
>
<q-card>
<q-card-section>

View File

@ -143,7 +143,7 @@ function filterType(val, update) {
<template #no-option>
<q-item>
<q-item-section class="text-grey">
{{ t('components.smartCard.noData') }}
{{ t('wagon.warnings.noData') }}
</q-item-section>
</q-item>
</template>

View File

@ -0,0 +1,72 @@
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
import { createWrapper, axios } from 'app/test/vitest/helper';
import WagonCreate from 'pages/Wagon/WagonCreate.vue';
describe('WagonCreate', () => {
let vm;
beforeAll(() => {
vm = createWrapper(WagonCreate, {propsData: {
id: 1,
}}).vm;
});
afterEach(() => {
vi.clearAllMocks();
});
describe('onSubmit()', () => {
it('should create or update a wagon', async () => {
vi.spyOn(axios, 'patch').mockResolvedValue({ data: true });
vm.wagon = {
id: vm.entityId,
label: 1234,
plate: 'MOCK PLATE',
volume: 50,
typeFk: 1,
};
await vm.onSubmit();
expect(axios.patch).toHaveBeenCalledWith(
`Wagons`, vm.wagon
);
});
});
describe('onReset()', () => {
it('should reset wagon', async () => {
vm.originalData = {
label: 1234,
plate: 'Original',
volume: 200,
typeFk: 1,
};
vm.wagon = {
label: 4321,
plate: 'Edited',
volume: 50,
typeFk: 2,
};
await vm.onReset();
expect(vm.wagon).toEqual(vm.originalData);
});
});
describe('fetch()', () => {
it('should fetch data', async () => {
vi.spyOn(axios, 'get').mockResolvedValue({ data: true });
await vm.fetch();
expect(axios.get).toHaveBeenCalledWith(
`WagonTypes`
);
expect(axios.get).toHaveBeenCalledWith(
`Wagons/1`
);
});
});
});