From d69954bb367481e87c779ee5c82cd4fc9110b79a Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Wed, 21 Feb 2018 13:10:23 +0100 Subject: [PATCH] itemBotanical fixed with test --- client/item/src/botanical/item-botanical.js | 5 ++- .../item/src/botanical/item-botanical.spec.js | 34 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 client/item/src/botanical/item-botanical.spec.js diff --git a/client/item/src/botanical/item-botanical.js b/client/item/src/botanical/item-botanical.js index 032d46b21..c747b6b0d 100644 --- a/client/item/src/botanical/item-botanical.js +++ b/client/item/src/botanical/item-botanical.js @@ -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']; diff --git a/client/item/src/botanical/item-botanical.spec.js b/client/item/src/botanical/item-botanical.spec.js new file mode 100644 index 000000000..f4e0e52d9 --- /dev/null +++ b/client/item/src/botanical/item-botanical.spec.js @@ -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(); + }); + }); + }); +});