diff --git a/src/components/SmartCard.vue b/src/components/SmartCard.vue index f3bf56b1d..a03725aee 100644 --- a/src/components/SmartCard.vue +++ b/src/components/SmartCard.vue @@ -1,19 +1,150 @@ + + diff --git a/src/components/__tests__/SmartCard.spec.js b/src/components/__tests__/SmartCard.spec.js new file mode 100644 index 000000000..467f2aadf --- /dev/null +++ b/src/components/__tests__/SmartCard.spec.js @@ -0,0 +1,101 @@ +import { jest, describe, expect, it, beforeAll } from '@jest/globals'; +import { createWrapper, axios, flushPromises } from 'app/tests/jest/jestHelpers'; +import SmartCard from '../SmartCard.vue'; + +const mockPush = jest.fn(); + +jest.mock('vue-router', () => ({ + useRouter: () => ({ + push: mockPush, + currentRoute: { value: 'myCurrentRoute' } + }), +})); + + +describe('SmartCard', () => { + let vm; + beforeAll(() => { + const options = { + attrs: { + url: '/api/customers', + sortBy: 'id DESC' + } + }; + vm = createWrapper(SmartCard, options).vm; + }); + + it('should call to the fetch() method and set the data on the rows property', async () => { + jest.spyOn(axios, 'get').mockResolvedValue({ + data: [ + { id: 1, name: 'Tony Stark' }, + { id: 2, name: 'Jessica Jones' }, + { id: 3, name: 'Bruce Wayne' }, + ] + }); + + const expectedPath = '/api/customers'; + const expectedOptions = { + params: { + filter: { + order: 'id DESC', + limit: 10, + skip: 0 + } + } + } + + //vm.pagination.page = 2; + + await vm.fetch(); + + await flushPromises(); + + expect(axios.get).toHaveBeenCalledWith(expectedPath, expectedOptions); + expect(vm.rows.length).toEqual(3); + + vm.rows = []; // Clear + }); + + it('should test', async () => { + jest.spyOn(axios, 'get').mockResolvedValue({ + data: [ + { id: 1, name: 'Tony Stark' }, + { id: 2, name: 'Jessica Jones' }, + { id: 3, name: 'Bruce Wayne' }, + ] + }); + + const expectedPath = '/api/customers'; + const expectedOptions = { + params: { + filter: { + order: 'id DESC', + limit: 10, + skip: 10 + } + } + } + + //await vm.fetch(); + //await flushPromises(); + + + //expect(axios.get).toHaveBeenCalledWith(expectedPath, expectedOptions); + //expect(vm.rows.length).toEqual(3); + + + + + + vm.pagination.page = 2; + + await vm.fetch(); + + await flushPromises(); + + expect(axios.get).toHaveBeenCalledWith(expectedPath, expectedOptions); + expect(vm.rows.length).toEqual(3); + + + }); +}); diff --git a/src/i18n/en/index.js b/src/i18n/en/index.js index 77a6f233e..7a27c8ca5 100644 --- a/src/i18n/en/index.js +++ b/src/i18n/en/index.js @@ -40,6 +40,12 @@ export default { list: 'List', createCustomer: 'Create customer', basicData: 'Basic Data' + }, + list: { + phone: 'Phone', + email: 'Email', + customerOrders: 'Display customer orders', + moreOptions: 'More options' } }, ticket: { @@ -56,5 +62,10 @@ export default { settings: 'Settings', logOut: 'Log Out', }, + smartCard: { + noData: 'No data to display', + openCard: 'View card', + openSummary: 'Open summary' + } }, }; diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index 104f169e5..82f136062 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -11,7 +11,7 @@ export default { favoriteModules: 'Módulos favoritos', theme: 'Tema', logOut: 'Cerrar sesión', - dataSaved: 'Datos guardados', + dataSaved: 'Datos guardados' }, moduleIndex: { allModules: 'Todos los módulos' @@ -40,6 +40,12 @@ export default { list: 'Listado', createCustomer: 'Crear cliente', basicData: 'Datos básicos' + }, + list: { + phone: 'Teléfono', + email: 'Email', + customerOrders: 'Mostrar órdenes del cliente', + moreOptions: 'Más opciones' } }, ticket: { @@ -56,5 +62,10 @@ export default { settings: 'Configuración', logOut: 'Cerrar sesión', }, + smartCard: { + noData: 'Sin datos que mostrar', + openCard: 'Ver ficha', + openSummary: 'Abrir detalles' + } }, }; diff --git a/src/pages/Customer/Card/CustomerBasicData.vue b/src/pages/Customer/Card/CustomerBasicData.vue index b4e913ad5..4c4c5626b 100644 --- a/src/pages/Customer/Card/CustomerBasicData.vue +++ b/src/pages/Customer/Card/CustomerBasicData.vue @@ -1,3 +1,5 @@ \ No newline at end of file + + Basic Data + + diff --git a/src/pages/Customer/CustomerList.vue b/src/pages/Customer/CustomerList.vue index b4ace86b4..bb0b4ef62 100644 --- a/src/pages/Customer/CustomerList.vue +++ b/src/pages/Customer/CustomerList.vue @@ -1,123 +1,10 @@