diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-24 15:08:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-24 15:08:01 +0300 |
commit | c6373a2cec855c6543a1e035c52099e102dd05ef (patch) | |
tree | 507c4d975e1bf559a008d997ad4b07dad14f397e /spec/frontend/lib | |
parent | 6593f1f627938f22090dec5221476772d3ed581d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/lib')
-rw-r--r-- | spec/frontend/lib/utils/datetime_utility_spec.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/datetime_utility_spec.js b/spec/frontend/lib/utils/datetime_utility_spec.js index 872779299d2..c32710196db 100644 --- a/spec/frontend/lib/utils/datetime_utility_spec.js +++ b/spec/frontend/lib/utils/datetime_utility_spec.js @@ -341,6 +341,16 @@ describe('prettyTime methods', () => { assertTimeUnits(twoDays, 3, 48, 0, 0); }); + + it('should correctly parse values when limitedToDays is true', () => { + const sevenDays = datetimeUtility.parseSeconds(648750, { + hoursPerDay: 24, + daysPerWeek: 7, + limitToDays: true, + }); + + assertTimeUnits(sevenDays, 12, 12, 7, 0); + }); }); describe('stringifyTime', () => { @@ -507,3 +517,32 @@ describe('secondsToDays', () => { expect(datetimeUtility.secondsToDays(270000)).toBe(3); }); }); + +describe('approximateDuration', () => { + it.each` + seconds + ${null} + ${{}} + ${[]} + ${-1} + `('returns a blank string for seconds=$seconds', ({ seconds }) => { + expect(datetimeUtility.approximateDuration(seconds)).toBe(''); + }); + + it.each` + seconds | approximation + ${0} | ${'less than a minute'} + ${25} | ${'less than a minute'} + ${45} | ${'1 minute'} + ${90} | ${'1 minute'} + ${100} | ${'1 minute'} + ${150} | ${'2 minutes'} + ${220} | ${'3 minutes'} + ${3000} | ${'about 1 hour'} + ${30000} | ${'about 8 hours'} + ${100000} | ${'1 day'} + ${180000} | ${'2 days'} + `('converts $seconds seconds to $approximation', ({ seconds, approximation }) => { + expect(datetimeUtility.approximateDuration(seconds)).toBe(approximation); + }); +}); |