57 lines
2.1 KiB
JavaScript
57 lines
2.1 KiB
JavaScript
import './index.js';
|
|
|
|
describe('Travel Component vnTravelDescriptorMenu', () => {
|
|
let controller;
|
|
let $httpBackend;
|
|
beforeEach(ngModule('travel'));
|
|
|
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
|
$httpBackend = _$httpBackend_;
|
|
const $element = angular.element('<vn-travel-descriptor-menu></vn-travel-descriptor-menu>');
|
|
controller = $componentController('vnTravelDescriptorMenu', {$element});
|
|
controller._travelId = 5;
|
|
}));
|
|
|
|
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});
|
|
});
|
|
});
|
|
|
|
describe('onCloneWithEntriesAccept()', () => {
|
|
it('should make an HTTP query and then call to the $state.go method with the returned id', () => {
|
|
jest.spyOn(controller.$state, 'go').mockReturnValue('ok');
|
|
|
|
$httpBackend.expect('POST', `Travels/${controller.travelId}/cloneWithEntries`).respond(200, 9);
|
|
controller.onCloneWithEntriesAccept();
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('travel.card.basicData', {
|
|
id: jasmine.any(Number)
|
|
});
|
|
});
|
|
});
|
|
});
|