salix/modules/travel/front/index/index.spec.js

51 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-10-25 11:29:05 +00:00
import './index.js';
describe('Travel Component vnTravelIndex', () => {
let controller;
2020-03-16 17:08:44 +00:00
let travel = {
2019-12-20 06:55:00 +00:00
id: 1,
warehouseInFk: 1,
totalEntries: 3,
isDelivered: false
2020-03-16 17:08:44 +00:00
};
2019-10-25 11:29:05 +00:00
2020-03-16 17:08:44 +00:00
beforeEach(ngModule('travel'));
2019-10-25 11:29:05 +00:00
beforeEach(angular.mock.inject($componentController => {
2020-03-18 11:55:22 +00:00
const $element = angular.element('<vn-travel-index></vn-travel-index>');
controller = $componentController('vnTravelIndex', {$element});
2019-12-20 06:55:00 +00:00
controller.$.summary = {show: jasmine.createSpy('show')};
2019-10-25 11:29:05 +00:00
}));
2019-12-20 06:55:00 +00:00
describe('preview()', () => {
it('should show the dialog summary', () => {
let event = new MouseEvent('click', {
bubbles: true,
cancelable: true
});
2020-03-16 17:08:44 +00:00
controller.preview(event, travel);
2019-10-25 11:29:05 +00:00
2019-12-20 06:55:00 +00:00
expect(controller.$.summary.show).toHaveBeenCalledWith();
2019-10-25 11:29:05 +00:00
});
2019-12-20 06:55:00 +00:00
});
2020-03-10 13:09:26 +00:00
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
2020-03-10 13:09:26 +00:00
};
const queryParams = JSON.stringify(travelParams);
controller.onCloneAccept(travel);
2020-03-10 13:09:26 +00:00
expect(controller.$state.go).toHaveBeenCalledWith('travel.create', {q: queryParams});
});
});
2019-10-25 11:29:05 +00:00
});