231801_dev_to_test #52
|
@ -416,6 +416,7 @@ export default {
|
||||||
label: 'Label'
|
label: 'Label'
|
||||||
},
|
},
|
||||||
warnings: {
|
warnings: {
|
||||||
|
noData: 'No data available',
|
||||||
nameNotEmpty: 'Name can not be empty',
|
nameNotEmpty: 'Name can not be empty',
|
||||||
labelNotEmpty: 'Label can not be empty',
|
labelNotEmpty: 'Label can not be empty',
|
||||||
plateNotEmpty: 'Plate can not be empty',
|
plateNotEmpty: 'Plate can not be empty',
|
||||||
|
|
|
@ -415,6 +415,7 @@ export default {
|
||||||
label: 'Etiqueta',
|
label: 'Etiqueta',
|
||||||
},
|
},
|
||||||
warnings: {
|
warnings: {
|
||||||
|
noData: 'Sin datos disponibles',
|
||||||
nameNotEmpty: 'El nombre no puede estar vacío',
|
nameNotEmpty: 'El nombre no puede estar vacío',
|
||||||
labelNotEmpty: 'La etiqueta no puede estar vacía',
|
labelNotEmpty: 'La etiqueta no puede estar vacía',
|
||||||
plateNotEmpty: 'La matrícula no puede estar vacía',
|
plateNotEmpty: 'La matrícula no puede estar vacía',
|
||||||
|
|
|
@ -320,7 +320,7 @@ function checkMaxHeight(pos) {
|
||||||
<q-dialog
|
<q-dialog
|
||||||
v-model="colorPickerActive"
|
v-model="colorPickerActive"
|
||||||
position="right"
|
position="right"
|
||||||
no-backdrop-dismiss="false"
|
:no-backdrop-dismiss="false"
|
||||||
>
|
>
|
||||||
<q-card>
|
<q-card>
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
|
|
|
@ -143,7 +143,7 @@ function filterType(val, update) {
|
||||||
<template #no-option>
|
<template #no-option>
|
||||||
<q-item>
|
<q-item>
|
||||||
<q-item-section class="text-grey">
|
<q-item-section class="text-grey">
|
||||||
{{ t('components.smartCard.noData') }}
|
{{ t('wagon.warnings.noData') }}
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -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`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue