import './index.js'; describe('Travel Component vnTravel', () => { let controller; beforeEach(ngModule('travel')); beforeEach(inject($componentController => { let $element = angular.element(`
`); controller = $componentController('vnTravel', {$element}); })); describe('fetchParams()', () => { it('should return a range of dates with passed scope days', () => { 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); const expectedParams = { shippedFrom, scopeDays: params.scopeDays, shippedTo }; 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); }); }); });