2018-05-25 08:03:45 +00:00
|
|
|
import './index.js';
|
2018-02-05 15:53:41 +00:00
|
|
|
|
|
|
|
describe('Item', () => {
|
|
|
|
describe('Component vnItemCreate', () => {
|
|
|
|
let $scope;
|
|
|
|
let $state;
|
|
|
|
let controller;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('item'));
|
2018-02-05 15:53:41 +00:00
|
|
|
|
2020-07-23 14:46:16 +00:00
|
|
|
beforeEach(inject(($componentController, $rootScope, _$state_) => {
|
2018-02-05 15:53:41 +00:00
|
|
|
$scope = $rootScope.$new();
|
|
|
|
$state = _$state_;
|
|
|
|
$scope.watcher = {
|
|
|
|
submit: () => {
|
|
|
|
return {
|
|
|
|
then: callback => {
|
|
|
|
callback({data: {id: 1}});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
2020-03-17 13:43:46 +00:00
|
|
|
const $element = angular.element('<vn-item-create></vn-item-create>');
|
|
|
|
controller = $componentController('vnItemCreate', {$element, $scope});
|
2018-02-05 15:53:41 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
describe('onSubmit()', () => {
|
|
|
|
it(`should call submit() on the watcher then expect a callback`, () => {
|
2020-02-26 12:22:52 +00:00
|
|
|
jest.spyOn($state, 'go');
|
2018-02-05 15:53:41 +00:00
|
|
|
controller.onSubmit();
|
|
|
|
|
2019-04-16 12:30:01 +00:00
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('item.card.basicData', {id: 1});
|
2018-02-05 15:53:41 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|