salix/client/item/src/create/create.spec.js

41 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-04-04 17:59:03 +00:00
import './create.js';
describe('Item', () => {
describe('Component vnItemCreate', () => {
let $componentController;
let $scope;
let $state;
let controller;
beforeEach(() => {
angular.mock.module('item');
});
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$state_) => {
$componentController = _$componentController_;
$scope = $rootScope.$new();
$state = _$state_;
$scope.watcher = {
submit: () => {
return {
then: callback => {
callback({data: {id: 1}});
}
};
}
};
controller = $componentController('vnItemCreate', {$scope: $scope});
}));
describe('onSubmit()', () => {
it(`should call submit() on the watcher then expect a callback`, () => {
spyOn($state, 'go');
controller.onSubmit();
expect(controller.$state.go).toHaveBeenCalledWith('item.card.data', {id: 1});
});
});
});
});