diff --git a/src/i18n/en/index.js b/src/i18n/en/index.js index deb6d28de..5b250ef97 100644 --- a/src/i18n/en/index.js +++ b/src/i18n/en/index.js @@ -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', diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index 7b892b28d..0c784231a 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -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', diff --git a/src/pages/Wagon/Type/WagonTypeCreate.vue b/src/pages/Wagon/Type/WagonTypeCreate.vue index 9dfc5baeb..c1d40b43f 100644 --- a/src/pages/Wagon/Type/WagonTypeCreate.vue +++ b/src/pages/Wagon/Type/WagonTypeCreate.vue @@ -320,7 +320,7 @@ function checkMaxHeight(pos) { diff --git a/src/pages/Wagon/WagonCreate.vue b/src/pages/Wagon/WagonCreate.vue index 3f24d9bde..e0ff6b022 100644 --- a/src/pages/Wagon/WagonCreate.vue +++ b/src/pages/Wagon/WagonCreate.vue @@ -143,7 +143,7 @@ function filterType(val, update) { diff --git a/test/vitest/__tests__/pages/Wagons/WagonCreate.spec.js b/test/vitest/__tests__/pages/Wagons/WagonCreate.spec.js new file mode 100644 index 000000000..9e977dada --- /dev/null +++ b/test/vitest/__tests__/pages/Wagons/WagonCreate.spec.js @@ -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` + ); + }); + }); +});