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

50 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-03-16 17:08:44 +00:00
import './index.js';
2021-02-02 11:37:00 +00:00
describe('Travel Component vnTravel', () => {
2020-03-16 17:08:44 +00:00
let controller;
beforeEach(ngModule('travel'));
2020-07-23 14:46:16 +00:00
beforeEach(inject($componentController => {
2020-03-16 17:08:44 +00:00
let $element = angular.element(`<div></div>`);
controller = $componentController('vnTravel', {$element});
}));
describe('fetchParams()', () => {
it('should return a range of dates with passed scope days', () => {
2021-01-29 10:45:35 +00:00
let params = controller.fetchParams({
scopeDays: 2
});
const shippedFrom = new Date();
shippedFrom.setHours(0, 0, 0, 0);
const shippedTo = new Date(shippedFrom.getTime());
shippedTo.setDate(shippedTo.getDate() + params.scopeDays);
shippedTo.setHours(23, 59, 59, 999);
2021-02-02 12:12:54 +00:00
const expectedParams = {
2021-01-29 10:45:35 +00:00
shippedFrom,
scopeDays: params.scopeDays,
shippedTo
2021-02-02 12:12:54 +00:00
};
2021-01-29 10:45:35 +00:00
expect(params).toEqual(expectedParams);
});
2021-02-02 10:49:42 +00:00
it('should return default value for scope days', () => {
2021-01-29 10:45:35 +00:00
let params = controller.fetchParams({
2021-02-02 10:49:42 +00:00
scopeDays: 1
2021-01-29 10:45:35 +00:00
});
expect(params.scopeDays).toEqual(1);
});
2021-02-02 13:00:35 +00:00
it('should return the given scope days', () => {
2021-01-29 10:45:35 +00:00
let params = controller.fetchParams({
scopeDays: 2
});
2021-02-02 10:49:42 +00:00
expect(params.scopeDays).toEqual(2);
2021-01-29 10:45:35 +00:00
});
2020-03-16 17:08:44 +00:00
});
});