diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2018-10-19 20:53:41 +0300 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2018-10-25 19:46:45 +0300 |
commit | 50222d4dc679dd3c9c8d8ff92a32f5691e607804 (patch) | |
tree | 7e5115f164e4f5e85eb3761f91ff2d02ed3b87b4 /spec | |
parent | 048ec287618324e295857be8976be418e4f09703 (diff) |
Add calculateRemainingMilliseconds() helper function
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/lib/utils/datetime_utility_spec.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/javascripts/lib/utils/datetime_utility_spec.js b/spec/javascripts/lib/utils/datetime_utility_spec.js index 2821f4d6793..de6b96aab57 100644 --- a/spec/javascripts/lib/utils/datetime_utility_spec.js +++ b/spec/javascripts/lib/utils/datetime_utility_spec.js @@ -352,3 +352,21 @@ describe('prettyTime methods', () => { }); }); }); + +describe('calculateRemainingMilliseconds', () => { + beforeEach(() => { + spyOn(Date, 'now').and.callFake(() => new Date('2063-04-04T00:42:00Z').getTime()); + }); + + it('calculates the remaining time for a given end date', () => { + const milliseconds = datetimeUtility.calculateRemainingMilliseconds('2063-04-04T01:44:03Z'); + + expect(milliseconds).toBe(3723000); + }); + + it('returns 0 if the end date has passed', () => { + const milliseconds = datetimeUtility.calculateRemainingMilliseconds('2063-04-03T00:00:00Z'); + + expect(milliseconds).toBe(0); + }); +}); |