salix/modules/travel/front/descriptor-menu/index.spec.js

40 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-11-16 18:04:37 +00:00
import './index.js';
describe('Travel Component vnTravelDescriptorMenu', () => {
let controller;
beforeEach(ngModule('travel'));
beforeEach(inject(($componentController, $state,) => {
const $element = angular.element('<vn-travel-descriptor-menu></vn-travel-descriptor-menu>');
controller = $componentController('vnTravelDescriptorMenu', {$element});
}));
describe('onCloneAccept()', () => {
it('should call state.go with the travel data', () => {
jest.spyOn(controller.$state, 'go').mockReturnValue('ok');
controller.travel = {
ref: 'the ref',
agencyFk: 'the agency',
shipped: 'the shipped date',
landed: 'the landing date',
warehouseInFk: 'the receiver warehouse',
warehouseOutFk: 'the sender warehouse'
};
controller.onCloneAccept();
const params = JSON.stringify({
ref: controller.travel.ref,
agencyModeFk: controller.travel.agencyFk,
shipped: controller.travel.shipped,
landed: controller.travel.landed,
warehouseInFk: controller.travel.warehouseInFk,
warehouseOutFk: controller.travel.warehouseOutFk
});
expect(controller.$state.go).toHaveBeenCalledWith('travel.create', {'q': params});
});
});
});