diff --git a/modules/item/front/basic-data/index.spec.js b/modules/item/front/basic-data/index.spec.js index e7578b54c..178fac278 100644 --- a/modules/item/front/basic-data/index.spec.js +++ b/modules/item/front/basic-data/index.spec.js @@ -2,26 +2,31 @@ import './index.js'; describe('vnItemBasicData', () => { describe('Component vnItemBasicData', () => { + let $httpBackend; let $scope; let controller; - let $timeout; + let $element; beforeEach(ngModule('item')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$timeout_) => { - $timeout = _$timeout_; + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { + $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); - controller = $componentController('vnItemBasicData', {$scope, $timeout}); - controller.$scope.watcher = {}; + $element = angular.element(''); + controller = $componentController('vnItemBasicData', {$element, $scope}); + controller.$.watcher = {}; + controller.$params.id = 1; + controller.item = {id: 1, name: 'Rainbow Coral'}; })); - describe('$onChanges()', () => { + describe('onIntrastatAccept()', () => { it('should pass the data to the watcher', () => { - const data = {item: {currentValue: 'the current value of an item'}}; - controller.$onChanges(data); - $timeout.flush(); + const newIntrastatId = 20; + $httpBackend.expect('PATCH', 'Items/1/createIntrastat').respond({id: 20}); + controller.onIntrastatAccept(); + $httpBackend.flush(); - expect(controller.$scope.watcher.data).toMatchSnapshot(); + expect(controller.item.intrastatFk).toEqual(newIntrastatId); }); }); });