import './index.js'; describe('vnItemBasicData', () => { describe('Component vnItemBasicData', () => { let $httpBackend; let $scope; let controller; beforeEach(ngModule('item')); beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); const $element = angular.element(''); controller = $componentController('vnItemBasicData', {$element, $scope}); controller.$.watcher = {}; controller.$params.id = 1; controller.item = {id: 1, name: 'Rainbow Coral'}; })); describe('onIntrastatAccept()', () => { it('should pass the data to the watcher', () => { const newIntrastatId = 20; $httpBackend.expect('PATCH', 'Items/1/createIntrastat').respond({id: 20}); controller.onIntrastatAccept(); $httpBackend.flush(); expect(controller.item.intrastatFk).toEqual(newIntrastatId); }); }); }); });