salix/modules/agency/front/create/index.spec.js

42 lines
1.1 KiB
JavaScript

import './index';
import watcher from 'core/mocks/watcher';
describe('Agency Component vnZoneCreate', () => {
let $scope;
let $state;
let controller;
beforeEach(angular.mock.module('agency', $translateProvider => {
$translateProvider.translations('en', {});
}));
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}));
});
});
});