salix/modules/item/front/basic-data/index.spec.js

33 lines
1.1 KiB
JavaScript
Raw Normal View History

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;
beforeEach(ngModule('item'));
2019-09-20 14:39:20 +00:00
2020-07-23 14:46:16 +00:00
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
2020-02-17 12:32:12 +00:00
$httpBackend = _$httpBackend_;
2019-09-20 14:39:20 +00:00
$scope = $rootScope.$new();
2020-03-17 13:43:46 +00:00
const $element = angular.element('<vn-item-basic-data></vn-item-basic-data>');
2020-02-17 12:32:12 +00:00
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
});
});
});
});