2019-12-09 11:15:19 +00:00
|
|
|
import './index';
|
|
|
|
import watcher from 'core/mocks/watcher';
|
|
|
|
|
|
|
|
describe('Travel Component vnTravelCreate', () => {
|
|
|
|
let $element;
|
|
|
|
let $scope;
|
|
|
|
let $state;
|
|
|
|
let controller;
|
|
|
|
|
|
|
|
beforeEach(ngModule('travel'));
|
|
|
|
|
|
|
|
beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_) => {
|
|
|
|
$scope = $rootScope.$new();
|
|
|
|
$state = _$state_;
|
|
|
|
$scope.watcher = watcher;
|
|
|
|
$element = angular.element('<div></div>');
|
|
|
|
controller = $componentController('vnTravelCreate', {$element, $scope});
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('onSubmit()', () => {
|
|
|
|
it(`should call submit() on the watcher then expect a callback`, () => {
|
2020-02-26 12:22:52 +00:00
|
|
|
jest.spyOn($state, 'go');
|
2019-12-09 11:15:19 +00:00
|
|
|
|
|
|
|
controller.onSubmit();
|
|
|
|
|
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('travel.card.summary', {id: 1234});
|
|
|
|
});
|
|
|
|
});
|
2020-03-10 13:09:26 +00:00
|
|
|
|
|
|
|
describe('$onChanges()', () => {
|
|
|
|
it('should update the travel data when stateParams.q is defined', () => {
|
|
|
|
controller.$stateParams = {q: {
|
|
|
|
ref: 1,
|
|
|
|
agencyModeFk: 1
|
|
|
|
}};
|
|
|
|
|
|
|
|
const result = {q: {
|
|
|
|
ref: 1,
|
|
|
|
agencyModeFk: 1
|
|
|
|
}};
|
|
|
|
controller.$onChanges();
|
|
|
|
|
|
|
|
expect(controller._travel).toBe(result);
|
|
|
|
});
|
|
|
|
});
|
2019-12-09 11:15:19 +00:00
|
|
|
});
|
|
|
|
|