import './index'; import watcher from 'core/mocks/watcher'; describe('Agency 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.location', Object({id: 1234})); }); }); });