2018-09-19 13:05:07 +00:00
|
|
|
import './index';
|
2018-12-10 07:43:57 +00:00
|
|
|
import {watcher} from '../../../helpers/watcherHelper';
|
2018-09-19 13:05:07 +00:00
|
|
|
|
2018-09-25 06:53:57 +00:00
|
|
|
describe('Agency', () => {
|
2018-09-19 13:05:07 +00:00
|
|
|
describe('Component vnZoneCreate', () => {
|
|
|
|
let $componentController;
|
|
|
|
let $httpBackend;
|
|
|
|
let $scope;
|
|
|
|
let $state;
|
|
|
|
let controller;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2018-09-25 06:53:57 +00:00
|
|
|
angular.mock.module('agency');
|
2018-09-19 13:05:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_, _$state_) => {
|
|
|
|
$componentController = _$componentController_;
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
|
|
|
|
$scope = $rootScope.$new();
|
|
|
|
$state = _$state_;
|
|
|
|
$scope.watcher = watcher;
|
2018-09-24 12:51:27 +00:00
|
|
|
$scope.watcher.submit = () => {
|
|
|
|
return {
|
|
|
|
then: callback => {
|
|
|
|
callback({data: {id: 1234}});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
2018-09-19 13:05:07 +00:00
|
|
|
controller = $componentController('vnZoneCreate', {$scope: $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});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|