itemBotanical fixed with test

This commit is contained in:
Daniel Herrero 2018-02-21 13:10:23 +01:00
parent 8d5b329839
commit d69954bb36
2 changed files with 38 additions and 1 deletions

View File

@ -5,7 +5,7 @@ class ItemBotanical {
this.$http = $http;
this.$state = $state;
}
$onInit() {
_getBotanical() {
let filter = {
where: {itemFk: this.$state.params.id},
include: [{relation: 'genus'}, {relation: 'specie'}]
@ -24,6 +24,9 @@ class ItemBotanical {
}
});
}
$onInit() {
this._getBotanical();
}
}
ItemBotanical.$inject = ['$http', '$state'];

View File

@ -0,0 +1,34 @@
import './item-botanical.js';
describe('ItemBotanical', () => {
describe('Component vnItemBotanical', () => {
let $componentController;
let $httpBackend;
let $state;
let controller;
beforeEach(() => {
angular.mock.module('item');
});
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => {
$componentController = _$componentController_;
$httpBackend = _$httpBackend_;
$state = {
params: {
id: 123
}
};
controller = $componentController('vnItemBotanical', {$state: $state});
}));
describe('_getBotanical()', () => {
it('should request to patch the propagation of botanical status', () => {
$httpBackend.whenGET('/item/api/ItemBotanicals?filter={"where":{"itemFk":123},"include":[{"relation":"genus"},{"relation":"specie"}]}').respond({data: 'item'});
$httpBackend.expectGET('/item/api/ItemBotanicals?filter={"where":{"itemFk":123},"include":[{"relation":"genus"},{"relation":"specie"}]}');
controller.$onInit();
$httpBackend.flush();
});
});
});
});