51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
import './index.js';
|
|
|
|
describe('Travel Component vnTravelIndex', () => {
|
|
let controller;
|
|
let travel = {
|
|
id: 1,
|
|
warehouseInFk: 1,
|
|
totalEntries: 3,
|
|
isDelivered: false
|
|
};
|
|
|
|
beforeEach(ngModule('travel'));
|
|
|
|
beforeEach(angular.mock.inject($componentController => {
|
|
const $element = angular.element('<vn-travel-index></vn-travel-index>');
|
|
controller = $componentController('vnTravelIndex', {$element});
|
|
controller.$.summary = {show: jasmine.createSpy('show')};
|
|
}));
|
|
|
|
describe('preview()', () => {
|
|
it('should show the dialog summary', () => {
|
|
let event = new MouseEvent('click', {
|
|
bubbles: true,
|
|
cancelable: true
|
|
});
|
|
controller.preview(event, travel);
|
|
|
|
expect(controller.$.summary.show).toHaveBeenCalledWith();
|
|
});
|
|
});
|
|
|
|
describe('onCloneAccept()', () => {
|
|
it('should call go() then update travelSelected in the controller', () => {
|
|
jest.spyOn(controller.$state, 'go');
|
|
|
|
const travel = {
|
|
ref: 1,
|
|
agencyFk: 1
|
|
};
|
|
const travelParams = {
|
|
ref: travel.ref,
|
|
agencyModeFk: travel.agencyFk
|
|
};
|
|
const queryParams = JSON.stringify(travelParams);
|
|
controller.onCloneAccept(travel);
|
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('travel.create', {q: queryParams});
|
|
});
|
|
});
|
|
});
|