From d09e47835e6cd2359d4e4456127152c21f3818c4 Mon Sep 17 00:00:00 2001 From: jorgebl Date: Mon, 8 Mar 2021 12:40:13 +0100 Subject: [PATCH] Rename the statements for correctly description the action --- modules/item/front/botanical/index.spec.js | 31 +++++++++++++--------- modules/item/front/botanical/locale/es.yml | 2 +- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/modules/item/front/botanical/index.spec.js b/modules/item/front/botanical/index.spec.js index f679a58f4..52aacd0f9 100644 --- a/modules/item/front/botanical/index.spec.js +++ b/modules/item/front/botanical/index.spec.js @@ -45,7 +45,7 @@ describe('vnItemBotanical', () => { expect(controller.$.genus.show).not.toHaveBeenCalledWith(); }); - it('should call preventDefault() and show() in genus field when the default is not prevented', () => { + it('should call show function in genus field when the default is not prevented', () => { const event = { defaultPrevented: false, preventDefault: () => {} @@ -76,7 +76,7 @@ describe('vnItemBotanical', () => { expect(controller.$.species.show).not.toHaveBeenCalledWith(); }); - it('should call preventDefault() and show() in species field when the default is not prevented', () => { + it('should call show function in species field when the default is not prevented', () => { const event = { defaultPrevented: false, preventDefault: () => {} @@ -93,7 +93,7 @@ describe('vnItemBotanical', () => { }); describe('onGenusAccept()', () => { - it('should throw an error if there is no name in the genus name field', () => { + it('should throw an error if genus field has not name', () => { jest.spyOn(controller.vnApp, 'showMessage'); controller.data = {}; @@ -104,10 +104,12 @@ describe('vnItemBotanical', () => { }); it('should do add the new genus', () => { - $httpBackend.whenRoute('GET', 'ItemBotanicals').respond({}); + const response = {data: 'MyResult'}; + $httpBackend.whenRoute('GET', 'ItemBotanicals').respond(response); $httpBackend.resetExpectations(); controller.data = { + id: 4, name: 'Anilius' }; @@ -115,25 +117,28 @@ describe('vnItemBotanical', () => { controller.onGenusAccept(); $httpBackend.flush(); + controller.onGenusResponse(controller.data.id); }); }); describe('onSpeciesAccept()', () => { - it('should throw an error if there is no name in the specie name field', () => { + it('should throw an error if species field has not name', () => { jest.spyOn(controller.vnApp, 'showMessage'); controller.data = {}; controller.onSpeciesAccept(); - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the specie can't be empty`); + expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the species can't be empty`); }); - it('should do add the new specie', () => { - $httpBackend.whenRoute('GET', 'ItemBotanicals').respond({}); + it('should do add the new species', () => { + const response = {data: 'MyResult'}; + $httpBackend.whenRoute('GET', 'ItemBotanicals').respond(response); $httpBackend.resetExpectations(); controller.data = { + id: 2, name: 'Spasiva' }; @@ -141,12 +146,14 @@ describe('vnItemBotanical', () => { controller.onSpeciesAccept(); $httpBackend.flush(); + controller.onSpeciesResponse(controller.data.id); }); }); describe('onSubmit()', () => { - it('should make an HTTP POST request to save the genus and species data', () => { - $httpBackend.whenRoute('GET', 'ItemBotanicals').respond({}); + it('should make HTTP POST request to save the genus and species data', () => { + const response = {data: 'MyResult'}; + $httpBackend.whenRoute('GET', 'ItemBotanicals').respond(response); $httpBackend.resetExpectations(); jest.spyOn(controller.$.watcher, 'updateOriginalData'); @@ -154,7 +161,7 @@ describe('vnItemBotanical', () => { jest.spyOn(controller.$.watcher, 'notifySaved'); controller.botanical = [{itemFk: 5, genusFk: 3, specieFk: 2}]; - $httpBackend.expectPATCH('ItemBotanicals', controller.botanical).respond({}); + $httpBackend.expectPATCH('ItemBotanicals', controller.botanical).respond(); controller.onSubmit(); $httpBackend.flush(); @@ -165,7 +172,7 @@ describe('vnItemBotanical', () => { }); describe('getBotanicalData()', () => { - it('should get the item data from itemBotanical', () => { + it('should get the species and genus data references of the item', () => { const response = ['MyResult']; $httpBackend.whenRoute('GET', `ItemBotanicals`).respond(response); controller.getBotanicalData(); diff --git a/modules/item/front/botanical/locale/es.yml b/modules/item/front/botanical/locale/es.yml index e22400654..e1234bd71 100644 --- a/modules/item/front/botanical/locale/es.yml +++ b/modules/item/front/botanical/locale/es.yml @@ -1,5 +1,5 @@ The genus has been created: El genus ha sido creado -The specie has been created: La especie ha sido creada +The species has been created: La especie ha sido creada Latin species name: Nombre de la especie en latín Latin genus name: Nombre del genus en latín Species: Especie \ No newline at end of file