mirror of
https://github.com/weaveworks/scope.git
synced 2026-08-19 04:16:21 +00:00
Improved the duration parsing on frontend.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import moment from 'moment';
|
||||
|
||||
|
||||
describe('StringUtils', () => {
|
||||
const StringUtils = require('../string-utils');
|
||||
@@ -29,4 +31,20 @@ describe('StringUtils', () => {
|
||||
expect(f('0.24.3.4')).toBe('000.024.003.004');
|
||||
});
|
||||
});
|
||||
|
||||
describe('humanizedRoundedDownDuration', () => {
|
||||
const f = StringUtils.humanizedRoundedDownDuration;
|
||||
|
||||
it('it should return the humanized duration', () => {
|
||||
expect(f(moment.duration(0))).toBe('now');
|
||||
expect(f(moment.duration(0.9 * 1000))).toBe('now');
|
||||
expect(f(moment.duration(1 * 1000))).toBe('1 second');
|
||||
expect(f(moment.duration(8.62 * 60 * 1000))).toBe('8 minutes');
|
||||
expect(f(moment.duration(14.99 * 60 * 60 * 1000))).toBe('14 hours');
|
||||
expect(f(moment.duration(5.2 * 24 * 60 * 60 * 1000))).toBe('5 days');
|
||||
expect(f(moment.duration(11.8 * 30 * 24 * 60 * 60 * 1000))).toBe('11 months');
|
||||
expect(f(moment.duration(12.8 * 30 * 24 * 60 * 60 * 1000))).toBe('1 year');
|
||||
expect(f(moment.duration(9.4 * 12 * 30 * 24 * 60 * 60 * 1000))).toBe('9 years');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user