diff options
Diffstat (limited to 'spec/frontend/lib')
-rw-r--r-- | spec/frontend/lib/utils/datetime/time_spent_utility_spec.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/datetime/time_spent_utility_spec.js b/spec/frontend/lib/utils/datetime/time_spent_utility_spec.js new file mode 100644 index 00000000000..15e056e45d0 --- /dev/null +++ b/spec/frontend/lib/utils/datetime/time_spent_utility_spec.js @@ -0,0 +1,25 @@ +import { formatTimeSpent } from '~/lib/utils/datetime/time_spent_utility'; + +describe('Time spent utils', () => { + describe('formatTimeSpent', () => { + describe('with limitToHours false', () => { + it('formats 34500 seconds to `1d 1h 35m`', () => { + expect(formatTimeSpent(34500)).toEqual('1d 1h 35m'); + }); + + it('formats -34500 seconds to `- 1d 1h 35m`', () => { + expect(formatTimeSpent(-34500)).toEqual('- 1d 1h 35m'); + }); + }); + + describe('with limitToHours true', () => { + it('formats 34500 seconds to `9h 35m`', () => { + expect(formatTimeSpent(34500, true)).toEqual('9h 35m'); + }); + + it('formats -34500 seconds to `- 9h 35m`', () => { + expect(formatTimeSpent(-34500, true)).toEqual('- 9h 35m'); + }); + }); + }); +}); |