diff options
author | Phil Hughes <me@iamphill.com> | 2018-06-07 20:32:06 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-06-07 20:32:06 +0300 |
commit | 249dafdf36f59d849ae38192a35bc4c804d2f240 (patch) | |
tree | 5182dcb350d71da1eb3c48b6d892accbf781be29 /spec | |
parent | 047aa493280353530d9b10da75e7c058a1f15481 (diff) | |
parent | dd7a59bf94849f578ebc8f65aa7acbd0ed7c8f8e (diff) |
Merge branch 'ce-4936-roadmap-navigation-presets' into 'master'
CE backport: Add timeframe helper methods
See merge request gitlab-org/gitlab-ce!19553
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/datetime_utility_spec.js | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/spec/javascripts/datetime_utility_spec.js b/spec/javascripts/datetime_utility_spec.js index a8d09202154..e224ed46d18 100644 --- a/spec/javascripts/datetime_utility_spec.js +++ b/spec/javascripts/datetime_utility_spec.js @@ -149,23 +149,22 @@ describe('getSundays', () => { }); }); -describe('getTimeframeWindow', () => { - it('returns array of dates representing a timeframe based on provided length and date', () => { - const date = new Date(2018, 0, 1); +describe('getTimeframeWindowFrom', () => { + it('returns array of date objects upto provided length start with provided startDate', () => { + const startDate = new Date(2018, 0, 1); const mockTimeframe = [ - new Date(2017, 9, 1), - new Date(2017, 10, 1), - new Date(2017, 11, 1), new Date(2018, 0, 1), new Date(2018, 1, 1), - new Date(2018, 2, 31), + new Date(2018, 2, 1), + new Date(2018, 3, 1), + new Date(2018, 4, 31), ]; - const timeframe = datetimeUtility.getTimeframeWindow(6, date); - - expect(timeframe.length).toBe(6); + const timeframe = datetimeUtility.getTimeframeWindowFrom(startDate, 5); + expect(timeframe.length).toBe(5); timeframe.forEach((timeframeItem, index) => { - expect(timeframeItem.getFullYear() === mockTimeframe[index].getFullYear()).toBeTruthy(); - expect(timeframeItem.getMonth() === mockTimeframe[index].getMonth()).toBeTruthy(); + console.log(timeframeItem); + expect(timeframeItem.getFullYear() === mockTimeframe[index].getFullYear()).toBe(true); + expect(timeframeItem.getMonth() === mockTimeframe[index].getMonth()).toBe(true); expect(timeframeItem.getDate() === mockTimeframe[index].getDate()).toBeTruthy(); }); }); |