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()', () => {
|
||||
it('should do nothing in genus field if it default is prevented', () => {
|
||||
const event = {
|
||||
|
@ -93,7 +98,7 @@ describe('vnItemBotanical', () => {
|
|||
});
|
||||
|
||||
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');
|
||||
|
||||
controller.data = {};
|
||||
|
@ -103,11 +108,7 @@ describe('vnItemBotanical', () => {
|
|||
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the genus can't be empty`);
|
||||
});
|
||||
|
||||
it('should do add the new genus', () => {
|
||||
const response = {data: 'MyResult'};
|
||||
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond(response);
|
||||
$httpBackend.resetExpectations();
|
||||
|
||||
it('should add the new genus', () => {
|
||||
controller.data = {
|
||||
id: 4,
|
||||
name: 'Anilius'
|
||||
|
@ -117,12 +118,15 @@ describe('vnItemBotanical', () => {
|
|||
|
||||
controller.onGenusAccept();
|
||||
$httpBackend.flush();
|
||||
|
||||
controller.onGenusResponse(controller.data);
|
||||
|
||||
expect(controller.botanical.genusFk).toEqual(controller.data.id);
|
||||
});
|
||||
});
|
||||
|
||||
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');
|
||||
|
||||
controller.data = {};
|
||||
|
@ -132,11 +136,7 @@ describe('vnItemBotanical', () => {
|
|||
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the species can't be empty`);
|
||||
});
|
||||
|
||||
it('should do add the new species', () => {
|
||||
const response = {data: 'MyResult'};
|
||||
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond(response);
|
||||
$httpBackend.resetExpectations();
|
||||
|
||||
it('should add the new species', () => {
|
||||
controller.data = {
|
||||
id: 2,
|
||||
name: 'Spasiva'
|
||||
|
@ -152,10 +152,6 @@ describe('vnItemBotanical', () => {
|
|||
|
||||
describe('onSubmit()', () => {
|
||||
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, 'check');
|
||||
jest.spyOn(controller.$.watcher, 'notifySaved');
|
||||
|
@ -172,12 +168,10 @@ describe('vnItemBotanical', () => {
|
|||
|
||||
describe('getBotanicalData()', () => {
|
||||
it('should get the species and genus data references of the item', () => {
|
||||
const response = ['MyResult'];
|
||||
$httpBackend.whenRoute('GET', `ItemBotanicals`).respond(response);
|
||||
controller.getBotanicalData();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.botanical).toEqual(response[0]);
|
||||
expect(controller.botanical).toEqual(controller.$params);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue