diff --git a/modules/route/front/main/index.spec.js b/modules/route/front/main/index.spec.js index b6df9fd73..e5724b493 100644 --- a/modules/route/front/main/index.spec.js +++ b/modules/route/front/main/index.spec.js @@ -38,20 +38,12 @@ describe('Route Component vnRoute', () => { expect(params.scopeDays).toEqual(1); }); - it('should return a number value in scope days', () => { + it('should return the given scope days', () => { let params = controller.fetchParams({ scopeDays: 2 }); expect(params.scopeDays).toEqual(2); }); - - it('should throw an error when scope days is not equal a number', () => { - let params = controller.fetchParams({ - scopeDays: 'ScopeDayNoNumber' - }); - - expect(params.scopeDays).toBe('ScopeDayNoNumber'); - }); }); }); diff --git a/modules/travel/front/main/index.spec.js b/modules/travel/front/main/index.spec.js index 96d819a6f..6d9db4dc8 100644 --- a/modules/travel/front/main/index.spec.js +++ b/modules/travel/front/main/index.spec.js @@ -12,29 +12,38 @@ describe('Travel Component vnTravel', () => { describe('fetchParams()', () => { it('should return a range of dates with passed scope days', () => { - /** - * Calculates the difference in days between two dates, it also - * accounts for cases where the two dates in question span a - * daylight saving time (DST) change. - * - * @param {Date} a The start date - * @param {Date} b The end date - * @return {Number} The difference in 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 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); - let params = controller.fetchParams({scopeDays: 2}); - const diff = diffInDays( - params.shippedFrom, - new Date(params.shippedTo.getTime() + 1) - ); + const expectedParams = { + shippedFrom, + scopeDays: params.scopeDays, + shippedTo + }; - expect(diff).toEqual(3); + expect(params).toEqual(expectedParams); + }); + + it('should return default value for scope days', () => { + let params = controller.fetchParams({ + scopeDays: 1 + }); + + expect(params.scopeDays).toEqual(1); + }); + + it('should return the given scope days', () => { + let params = controller.fetchParams({ + scopeDays: 2 + }); + + expect(params.scopeDays).toEqual(2); }); }); }); diff --git a/modules/travel/front/search-panel/index.html b/modules/travel/front/search-panel/index.html index afc041f66..8e7f4140d 100644 --- a/modules/travel/front/search-panel/index.html +++ b/modules/travel/front/search-panel/index.html @@ -1,6 +1,6 @@