41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
import './index';
|
|
import watcher from 'core/mocks/watcher';
|
|
|
|
describe('Zone Component vnZoneCreate', () => {
|
|
let $scope;
|
|
let $state;
|
|
let controller;
|
|
|
|
beforeEach(ngModule('zone'));
|
|
|
|
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}});
|
|
}
|
|
};
|
|
};
|
|
const $element = angular.element('<vn-zone-create></vn-zone-create>');
|
|
controller = $componentController('vnZoneCreate', {$element, $scope});
|
|
}));
|
|
|
|
describe('onSubmit()', () => {
|
|
it(`should call submit() on the watcher then expect a callback`, () => {
|
|
jest.spyOn($state, 'go');
|
|
|
|
controller.zone = {
|
|
name: 'Zone One'
|
|
};
|
|
|
|
controller.onSubmit();
|
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('zone.card.location', Object({id: 1234}));
|
|
});
|
|
});
|
|
});
|
|
|