2019-09-20 14:39:20 +00:00
|
|
|
import './index.js';
|
|
|
|
|
|
|
|
describe('vnItemBasicData', () => {
|
|
|
|
describe('Component vnItemBasicData', () => {
|
2020-02-17 12:32:12 +00:00
|
|
|
let $httpBackend;
|
2019-09-20 14:39:20 +00:00
|
|
|
let $scope;
|
|
|
|
let controller;
|
2020-02-17 12:32:12 +00:00
|
|
|
let $element;
|
2019-09-20 14:39:20 +00:00
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('item'));
|
2019-09-20 14:39:20 +00:00
|
|
|
|
2020-02-17 12:32:12 +00:00
|
|
|
beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => {
|
|
|
|
$httpBackend = _$httpBackend_;
|
2019-09-20 14:39:20 +00:00
|
|
|
$scope = $rootScope.$new();
|
2020-02-17 12:32:12 +00:00
|
|
|
$element = angular.element('<vn-item-basic-data></vn-item-basic-data>');
|
|
|
|
controller = $componentController('vnItemBasicData', {$element, $scope});
|
|
|
|
controller.$.watcher = {};
|
|
|
|
controller.$params.id = 1;
|
|
|
|
controller.item = {id: 1, name: 'Rainbow Coral'};
|
2019-09-20 14:39:20 +00:00
|
|
|
}));
|
|
|
|
|
2020-02-17 12:32:12 +00:00
|
|
|
describe('onIntrastatAccept()', () => {
|
2019-09-20 14:39:20 +00:00
|
|
|
it('should pass the data to the watcher', () => {
|
2020-02-17 12:32:12 +00:00
|
|
|
const newIntrastatId = 20;
|
|
|
|
$httpBackend.expect('PATCH', 'Items/1/createIntrastat').respond({id: 20});
|
|
|
|
controller.onIntrastatAccept();
|
|
|
|
$httpBackend.flush();
|
2019-09-20 14:39:20 +00:00
|
|
|
|
2020-02-17 12:32:12 +00:00
|
|
|
expect(controller.item.intrastatFk).toEqual(newIntrastatId);
|
2019-09-20 14:39:20 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|