import './index.js'; describe('Route Component vnRoute', () => { let controller; beforeEach(ngModule('route')); beforeEach(inject($componentController => { let $element = angular.element(`
`); 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); }); }); });