From d8a2302b181ae0d75dd00426f7ae55342ecb060e Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 15 Sep 2021 13:25:26 +0200 Subject: [PATCH] refactor(newbankentity): both client.billingdata and supplier.account now use newbankentity component --- modules/client/front/billing-data/index.html | 55 ++----------------- modules/client/front/billing-data/index.js | 7 +-- .../client/front/billing-data/index.spec.js | 18 ++---- .../client/front/billing-data/locale/es.yml | 3 +- modules/supplier/front/account/index.html | 1 + modules/supplier/front/account/index.spec.js | 2 +- 6 files changed, 16 insertions(+), 70 deletions(-) diff --git a/modules/client/front/billing-data/index.html b/modules/client/front/billing-data/index.html index b9c20ec24..ae1ad85a5 100644 --- a/modules/client/front/billing-data/index.html +++ b/modules/client/front/billing-data/index.html @@ -108,53 +108,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + \ No newline at end of file diff --git a/modules/client/front/billing-data/index.js b/modules/client/front/billing-data/index.js index 2dda347b9..dd43a661e 100644 --- a/modules/client/front/billing-data/index.js +++ b/modules/client/front/billing-data/index.js @@ -42,12 +42,11 @@ export default class Controller extends Section { this.newBankEntity = { countryFk: Number.parseInt(this.client.countryFk) }; - this.$.bankEntityDialog.show(); + this.$.bankEntity.open(); } - onBankEntityAccept() { - return this.$http.post(`BankEntities`, this.newBankEntity) - .then(res => this.client.bankEntityFk = res.data.id); + onResponse(response) { + this.client.bankEntityFk = response.id; } get ibanCountry() { diff --git a/modules/client/front/billing-data/index.spec.js b/modules/client/front/billing-data/index.spec.js index 95700cb5a..60cc4025c 100644 --- a/modules/client/front/billing-data/index.spec.js +++ b/modules/client/front/billing-data/index.spec.js @@ -35,20 +35,12 @@ describe('Client', () => { }); }); - describe('onBankEntityAccept()', () => { - it('should request to create a new bank entity', () => { - let newBankEntity = { - name: 'My new bank entity', - bic: 'ES123', - countryFk: 1, - id: 999 - }; - controller.newBankEntity = newBankEntity; - $httpBackend.expectPOST('BankEntities', newBankEntity).respond({id: 999}); - controller.onBankEntityAccept(); - $httpBackend.flush(); + describe('onResponse()', () => { + it('should assign the response id to the client bankEntityFk', () => { + const expectedResponse = {id: 999}; + controller.onResponse(expectedResponse); - expect(controller.client.bankEntityFk).toEqual(newBankEntity.id); + expect(controller.client.bankEntityFk).toEqual(expectedResponse.id); }); }); diff --git a/modules/client/front/billing-data/locale/es.yml b/modules/client/front/billing-data/locale/es.yml index a7ecbbdae..0052ee403 100644 --- a/modules/client/front/billing-data/locale/es.yml +++ b/modules/client/front/billing-data/locale/es.yml @@ -14,5 +14,4 @@ Received core VNL: Recibido core VNL Received B2B VNL: Recibido B2B VNL Save: Guardar New bank entity: Nueva entidad bancaria -Name can't be empty: El nombre no puede quedar vacío -Entity Code: Código \ No newline at end of file +Name can't be empty: El nombre no puede quedar vacío \ No newline at end of file diff --git a/modules/supplier/front/account/index.html b/modules/supplier/front/account/index.html index 7264f6f2c..c8ec8ba31 100644 --- a/modules/supplier/front/account/index.html +++ b/modules/supplier/front/account/index.html @@ -65,6 +65,7 @@ + { expect(controller.$.bankEntity.open).toHaveBeenCalledWith(); }); - it('should request to create a new bank entity', () => { + it('should now request to create a new bank entity', () => { controller.bankEntity = { name: 'My new bank entity', bic: 'ES1234',