42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
import './index';
|
|
import watcher from 'core/mocks/watcher';
|
|
|
|
describe('Travel Component vnTravelCreate', () => {
|
|
let $scope;
|
|
let $state;
|
|
let controller;
|
|
|
|
beforeEach(ngModule('travel'));
|
|
|
|
beforeEach(inject(($componentController, $rootScope, _$state_) => {
|
|
$scope = $rootScope.$new();
|
|
$state = _$state_;
|
|
$scope.watcher = watcher;
|
|
const $element = angular.element('<vn-travel-create></vn-travel-create>');
|
|
controller = $componentController('vnTravelCreate', {$element, $scope});
|
|
}));
|
|
|
|
describe('onSubmit()', () => {
|
|
it(`should call submit() on the watcher then expect a callback`, () => {
|
|
jest.spyOn($state, 'go');
|
|
|
|
controller.onSubmit();
|
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('travel.card.basicData', {id: 1234});
|
|
});
|
|
});
|
|
|
|
describe('$onChanges()', () => {
|
|
it('should update the travel data when $params.q is defined', () => {
|
|
controller.$params = {q: '{"ref": 1,"agencyModeFk": 1}'};
|
|
|
|
const params = {q: '{"ref": 1, "agencyModeFk": 1}'};
|
|
const json = JSON.parse(params.q);
|
|
|
|
controller.$onChanges();
|
|
|
|
expect(controller.travel).toEqual(json);
|
|
});
|
|
});
|
|
});
|