Added main spec and fixed line on search-panel spec
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
d8c4fa1e22
commit
e205ebba72
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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 = {};
|
||||
|
|
Loading…
Reference in New Issue