QA rename some descriptions in test and reworked the test
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
5cb959f5b8
commit
1922280c61
|
@ -30,6 +30,11 @@ describe('vnItemBotanical', () => {
|
||||||
}};
|
}};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
const response = {data: 'MyResult'};
|
||||||
|
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond(response);
|
||||||
|
});
|
||||||
|
|
||||||
describe('showGenus()', () => {
|
describe('showGenus()', () => {
|
||||||
it('should do nothing in genus field if it default is prevented', () => {
|
it('should do nothing in genus field if it default is prevented', () => {
|
||||||
const event = {
|
const event = {
|
||||||
|
@ -93,7 +98,7 @@ describe('vnItemBotanical', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onGenusAccept()', () => {
|
describe('onGenusAccept()', () => {
|
||||||
it('should throw an error if genus field has not name', () => {
|
it('should throw an error if the item botanical has no genus name', () => {
|
||||||
jest.spyOn(controller.vnApp, 'showMessage');
|
jest.spyOn(controller.vnApp, 'showMessage');
|
||||||
|
|
||||||
controller.data = {};
|
controller.data = {};
|
||||||
|
@ -103,11 +108,7 @@ describe('vnItemBotanical', () => {
|
||||||
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the genus can't be empty`);
|
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the genus can't be empty`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should do add the new genus', () => {
|
it('should add the new genus', () => {
|
||||||
const response = {data: 'MyResult'};
|
|
||||||
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond(response);
|
|
||||||
$httpBackend.resetExpectations();
|
|
||||||
|
|
||||||
controller.data = {
|
controller.data = {
|
||||||
id: 4,
|
id: 4,
|
||||||
name: 'Anilius'
|
name: 'Anilius'
|
||||||
|
@ -117,12 +118,15 @@ describe('vnItemBotanical', () => {
|
||||||
|
|
||||||
controller.onGenusAccept();
|
controller.onGenusAccept();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
controller.onGenusResponse(controller.data);
|
controller.onGenusResponse(controller.data);
|
||||||
|
|
||||||
|
expect(controller.botanical.genusFk).toEqual(controller.data.id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onSpeciesAccept()', () => {
|
describe('onSpeciesAccept()', () => {
|
||||||
it('should throw an error if species field has not name', () => {
|
it('should throw an error if the item botanical has no species name', () => {
|
||||||
jest.spyOn(controller.vnApp, 'showMessage');
|
jest.spyOn(controller.vnApp, 'showMessage');
|
||||||
|
|
||||||
controller.data = {};
|
controller.data = {};
|
||||||
|
@ -132,11 +136,7 @@ describe('vnItemBotanical', () => {
|
||||||
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the species can't be empty`);
|
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the species can't be empty`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should do add the new species', () => {
|
it('should add the new species', () => {
|
||||||
const response = {data: 'MyResult'};
|
|
||||||
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond(response);
|
|
||||||
$httpBackend.resetExpectations();
|
|
||||||
|
|
||||||
controller.data = {
|
controller.data = {
|
||||||
id: 2,
|
id: 2,
|
||||||
name: 'Spasiva'
|
name: 'Spasiva'
|
||||||
|
@ -152,10 +152,6 @@ describe('vnItemBotanical', () => {
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it('should make HTTP POST request to save the genus and species data', () => {
|
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');
|
jest.spyOn(controller.$.watcher, 'updateOriginalData');
|
||||||
jest.spyOn(controller.$.watcher, 'check');
|
jest.spyOn(controller.$.watcher, 'check');
|
||||||
jest.spyOn(controller.$.watcher, 'notifySaved');
|
jest.spyOn(controller.$.watcher, 'notifySaved');
|
||||||
|
@ -172,12 +168,10 @@ describe('vnItemBotanical', () => {
|
||||||
|
|
||||||
describe('getBotanicalData()', () => {
|
describe('getBotanicalData()', () => {
|
||||||
it('should get the species and genus data references of the item', () => {
|
it('should get the species and genus data references of the item', () => {
|
||||||
const response = ['MyResult'];
|
|
||||||
$httpBackend.whenRoute('GET', `ItemBotanicals`).respond(response);
|
|
||||||
controller.getBotanicalData();
|
controller.getBotanicalData();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.botanical).toEqual(response[0]);
|
expect(controller.botanical).toEqual(controller.$params);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue