Added main spec and fixed line on search-panel spec
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Jorge Padawan 2021-01-20 14:49:06 +01:00
parent d8c4fa1e22
commit e205ebba72
2 changed files with 32 additions and 1 deletions

View File

@ -0,0 +1,31 @@
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', () => {
function diffInDays(a, b) {
const utc1 = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());
const utc2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());
const msInDay = 86400 * 1000;
return Math.floor((utc2 - utc1) / msInDay);
}
let params = controller.fetchParams({scopeDays: 2});
const diff = diffInDays(
params.from,
new Date(params.to.getTime() + 1)
);
expect(diff).toEqual(3);
});
});
});

View File

@ -5,7 +5,7 @@ describe('Route Component vnRouteSearchPanel', () => {
beforeEach(ngModule('route'));
beforeEach(inject(($componentController, _$httpBackend_) => {
beforeEach(inject($componentController => {
controller = $componentController('vnRouteSearchPanel', {$element: null});
controller.$t = () => {};
controller.filter = {};