2021-01-20 13:49:06 +00:00
|
|
|
import './index.js';
|
|
|
|
|
|
|
|
describe('Route Component vnRoute', () => {
|
|
|
|
let controller;
|
|
|
|
|
|
|
|
beforeEach(ngModule('route'));
|
|
|
|
|
|
|
|
beforeEach(inject($componentController => {
|
|
|
|
let $element = angular.element(`<div></div>`);
|
|
|
|
controller = $componentController('vnRoute', {$element});
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('fetchParams()', () => {
|
|
|
|
it('should return a range of dates with passed scope days', () => {
|
2021-01-28 13:14:14 +00:00
|
|
|
let params = controller.fetchParams({
|
|
|
|
scopeDays: 2
|
|
|
|
});
|
2023-01-16 14:18:24 +00:00
|
|
|
const from = Date.vnNew();
|
2021-01-28 13:14:14 +00:00
|
|
|
from.setHours(0, 0, 0, 0);
|
|
|
|
const to = new Date(from.getTime());
|
|
|
|
to.setDate(to.getDate() + params.scopeDays);
|
|
|
|
to.setHours(23, 59, 59, 999);
|
|
|
|
|
2021-02-02 12:12:54 +00:00
|
|
|
const expectedParams = {
|
2021-01-28 13:14:14 +00:00
|
|
|
from,
|
|
|
|
scopeDays: params.scopeDays,
|
|
|
|
to
|
2021-02-02 12:12:54 +00:00
|
|
|
};
|
2021-01-28 13:14:14 +00:00
|
|
|
|
|
|
|
expect(params).toEqual(expectedParams);
|
|
|
|
});
|
|
|
|
|
2021-02-02 11:22:18 +00:00
|
|
|
it('should return default value for scope days', () => {
|
2021-01-28 13:14:14 +00:00
|
|
|
let params = controller.fetchParams({
|
2021-02-02 11:37:00 +00:00
|
|
|
scopeDays: 1
|
2021-01-28 13:14:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
expect(params.scopeDays).toEqual(1);
|
|
|
|
});
|
|
|
|
|
2021-02-02 13:00:35 +00:00
|
|
|
it('should return the given scope days', () => {
|
2021-01-28 13:14:14 +00:00
|
|
|
let params = controller.fetchParams({
|
|
|
|
scopeDays: 2
|
|
|
|
});
|
|
|
|
|
2021-02-02 11:22:18 +00:00
|
|
|
expect(params.scopeDays).toEqual(2);
|
2021-01-28 13:14:14 +00:00
|
|
|
});
|
2021-01-20 13:49:06 +00:00
|
|
|
});
|
|
|
|
});
|