import './index'; import watcher from 'core/mocks/watcher'; describe('Agency', () => { describe('Component vnZoneCreate', () => { let $scope; let $state; let controller; beforeEach(ngModule('agency')); beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_) => { $scope = $rootScope.$new(); $state = _$state_; $scope.watcher = watcher; $scope.watcher.submit = () => { return { then: callback => { callback({data: {id: 1234}}); } }; }; controller = $componentController('vnZoneCreate', {$scope}); })); describe('onSubmit()', () => { it(`should call submit() on the watcher then expect a callback`, () => { spyOn($state, 'go'); controller.zone = { name: 'Zone One' }; controller.onSubmit(); expect(controller.$state.go).toHaveBeenCalledWith('zone.card.basicData', {id: 1234}); }); }); }); });