2018-09-19 13:05:07 +00:00
|
|
|
import './index';
|
2018-12-27 11:54:16 +00:00
|
|
|
import watcher from 'core/mocks/watcher';
|
2018-09-19 13:05:07 +00:00
|
|
|
|
2019-04-26 14:10:51 +00:00
|
|
|
describe('Agency Component vnZoneCreate', () => {
|
|
|
|
let $scope;
|
|
|
|
let $state;
|
|
|
|
let controller;
|
|
|
|
|
2019-09-13 14:09:14 +00:00
|
|
|
beforeEach(angular.mock.module('agency', $translateProvider => {
|
|
|
|
$translateProvider.translations('en', {});
|
|
|
|
}));
|
2019-04-26 14:10:51 +00:00
|
|
|
|
|
|
|
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}});
|
|
|
|
}
|
2018-09-24 12:51:27 +00:00
|
|
|
};
|
2019-04-26 14:10:51 +00:00
|
|
|
};
|
|
|
|
controller = $componentController('vnZoneCreate', {$scope});
|
|
|
|
}));
|
2018-09-19 13:05:07 +00:00
|
|
|
|
2019-04-26 14:10:51 +00:00
|
|
|
describe('onSubmit()', () => {
|
|
|
|
it(`should call submit() on the watcher then expect a callback`, () => {
|
|
|
|
spyOn($state, 'go');
|
2018-09-19 13:05:07 +00:00
|
|
|
|
2019-04-26 14:10:51 +00:00
|
|
|
controller.zone = {
|
|
|
|
name: 'Zone One'
|
|
|
|
};
|
2018-09-19 13:05:07 +00:00
|
|
|
|
2019-04-26 14:10:51 +00:00
|
|
|
controller.onSubmit();
|
2018-09-19 13:05:07 +00:00
|
|
|
|
2019-04-26 14:10:51 +00:00
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('zone.card.location', Object({id: 1234}));
|
2018-09-19 13:05:07 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2019-04-26 14:10:51 +00:00
|
|
|
|