salix/client/route/src/zone/create/index.spec.js

44 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-09-19 13:05:07 +00:00
import './index';
import {watcher} from '../../../../helpers/watcherHelper';
describe('Route', () => {
describe('Component vnZoneCreate', () => {
let $componentController;
let $httpBackend;
let $scope;
let $state;
let controller;
beforeEach(() => {
angular.mock.module('route');
});
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_, _$state_) => {
$componentController = _$componentController_;
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$httpBackend.when('GET', 'claim/api/Claims/ClaimBeginnings').respond({});
$scope = $rootScope.$new();
$state = _$state_;
$scope.watcher = watcher;
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'
};
$httpBackend.expectPOST(`/route/api/Zones`).respond({id: 1234});
controller.onSubmit();
$httpBackend.flush();
expect(controller.$state.go).toHaveBeenCalledWith('zone.card.basicData', {id: 1234});
});
});
});
});