Rename the statements for correctly description the action
This commit is contained in:
parent
6e08a66343
commit
d09e47835e
|
@ -45,7 +45,7 @@ describe('vnItemBotanical', () => {
|
||||||
expect(controller.$.genus.show).not.toHaveBeenCalledWith();
|
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 = {
|
const event = {
|
||||||
defaultPrevented: false,
|
defaultPrevented: false,
|
||||||
preventDefault: () => {}
|
preventDefault: () => {}
|
||||||
|
@ -76,7 +76,7 @@ describe('vnItemBotanical', () => {
|
||||||
expect(controller.$.species.show).not.toHaveBeenCalledWith();
|
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 = {
|
const event = {
|
||||||
defaultPrevented: false,
|
defaultPrevented: false,
|
||||||
preventDefault: () => {}
|
preventDefault: () => {}
|
||||||
|
@ -93,7 +93,7 @@ describe('vnItemBotanical', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onGenusAccept()', () => {
|
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');
|
jest.spyOn(controller.vnApp, 'showMessage');
|
||||||
|
|
||||||
controller.data = {};
|
controller.data = {};
|
||||||
|
@ -104,10 +104,12 @@ describe('vnItemBotanical', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should do add the new genus', () => {
|
it('should do add the new genus', () => {
|
||||||
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond({});
|
const response = {data: 'MyResult'};
|
||||||
|
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond(response);
|
||||||
$httpBackend.resetExpectations();
|
$httpBackend.resetExpectations();
|
||||||
|
|
||||||
controller.data = {
|
controller.data = {
|
||||||
|
id: 4,
|
||||||
name: 'Anilius'
|
name: 'Anilius'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -115,25 +117,28 @@ describe('vnItemBotanical', () => {
|
||||||
|
|
||||||
controller.onGenusAccept();
|
controller.onGenusAccept();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
controller.onGenusResponse(controller.data.id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onSpeciesAccept()', () => {
|
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');
|
jest.spyOn(controller.vnApp, 'showMessage');
|
||||||
|
|
||||||
controller.data = {};
|
controller.data = {};
|
||||||
|
|
||||||
controller.onSpeciesAccept();
|
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', () => {
|
it('should do add the new species', () => {
|
||||||
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond({});
|
const response = {data: 'MyResult'};
|
||||||
|
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond(response);
|
||||||
$httpBackend.resetExpectations();
|
$httpBackend.resetExpectations();
|
||||||
|
|
||||||
controller.data = {
|
controller.data = {
|
||||||
|
id: 2,
|
||||||
name: 'Spasiva'
|
name: 'Spasiva'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -141,12 +146,14 @@ describe('vnItemBotanical', () => {
|
||||||
|
|
||||||
controller.onSpeciesAccept();
|
controller.onSpeciesAccept();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
controller.onSpeciesResponse(controller.data.id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it('should make an HTTP POST request to save the genus and species data', () => {
|
it('should make HTTP POST request to save the genus and species data', () => {
|
||||||
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond({});
|
const response = {data: 'MyResult'};
|
||||||
|
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond(response);
|
||||||
$httpBackend.resetExpectations();
|
$httpBackend.resetExpectations();
|
||||||
|
|
||||||
jest.spyOn(controller.$.watcher, 'updateOriginalData');
|
jest.spyOn(controller.$.watcher, 'updateOriginalData');
|
||||||
|
@ -154,7 +161,7 @@ describe('vnItemBotanical', () => {
|
||||||
jest.spyOn(controller.$.watcher, 'notifySaved');
|
jest.spyOn(controller.$.watcher, 'notifySaved');
|
||||||
|
|
||||||
controller.botanical = [{itemFk: 5, genusFk: 3, specieFk: 2}];
|
controller.botanical = [{itemFk: 5, genusFk: 3, specieFk: 2}];
|
||||||
$httpBackend.expectPATCH('ItemBotanicals', controller.botanical).respond({});
|
$httpBackend.expectPATCH('ItemBotanicals', controller.botanical).respond();
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
@ -165,7 +172,7 @@ describe('vnItemBotanical', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getBotanicalData()', () => {
|
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'];
|
const response = ['MyResult'];
|
||||||
$httpBackend.whenRoute('GET', `ItemBotanicals`).respond(response);
|
$httpBackend.whenRoute('GET', `ItemBotanicals`).respond(response);
|
||||||
controller.getBotanicalData();
|
controller.getBotanicalData();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
The genus has been created: El genus ha sido creado
|
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 species name: Nombre de la especie en latín
|
||||||
Latin genus name: Nombre del genus en latín
|
Latin genus name: Nombre del genus en latín
|
||||||
Species: Especie
|
Species: Especie
|
Loading…
Reference in New Issue