Updated unit test
gitea/salix/2113-item_data_add_instrastat This commit looks good
Details
gitea/salix/2113-item_data_add_instrastat This commit looks good
Details
This commit is contained in:
parent
844b27acb9
commit
7d8e88e884
|
@ -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('<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'};
|
||||
}));
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue