import './index.js'; describe('Item', () => { describe('Component vnItemCreate', () => { let $scope; let $state; let controller; beforeEach(ngModule('item')); beforeEach(inject(($componentController, $rootScope, _$state_) => { $scope = $rootScope.$new(); $state = _$state_; $scope.watcher = { submit: () => { return { then: callback => { callback({data: {id: 1}}); } }; } }; const $element = angular.element(''); controller = $componentController('vnItemCreate', {$element, $scope}); })); describe('onSubmit()', () => { it(`should call submit() on the watcher then expect a callback`, () => { jest.spyOn($state, 'go'); controller.onSubmit(); expect(controller.$state.go).toHaveBeenCalledWith('item.card.basicData', {id: 1}); }); }); }); });