Skip to content

Commit cb1233d

Browse files
committed
Improve humanizeRelativeTime tests
The tests were expecting the wrong results, except for the case where the time was less than a second. For less than a second ago, it makes sense to return "this minute". For times that are 2.001 minutes ago, it makes sense to return "2 minutes ago" rather then the previous behaviour of "3 minutes ago".
1 parent 06fd3a5 commit cb1233d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

extensions/ql-vscode/test/pure-tests/time.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ describe('Time', () => {
5454
});
5555

5656
it('should return a humanized duration negative', () => {
57-
expect(humanizeRelativeTime(-1)).to.eq('1 minute ago');
57+
expect(humanizeRelativeTime(-1)).to.eq('this minute');
5858
expect(humanizeRelativeTime(-1000 * 60)).to.eq('1 minute ago');
59-
expect(humanizeRelativeTime(-1000 * 60 - 1)).to.eq('2 minutes ago');
59+
expect(humanizeRelativeTime(-1000 * 60 - 1)).to.eq('1 minute ago');
6060
expect(humanizeRelativeTime(-1000 * 60 * 2)).to.eq('2 minutes ago');
61-
expect(humanizeRelativeTime(-1000 * 60 * 2 - 1)).to.eq('3 minutes ago');
61+
expect(humanizeRelativeTime(-1000 * 60 * 2 - 1)).to.eq('2 minutes ago');
62+
expect(humanizeRelativeTime(-1000 * 60 * 3)).to.eq('3 minutes ago');
6263
expect(humanizeRelativeTime(-1000 * 60 * 60)).to.eq('1 hour ago');
64+
expect(humanizeRelativeTime(-1000 * 60 * 60 - 1)).to.eq('1 hour ago');
6365
expect(humanizeRelativeTime(-1000 * 60 * 60 * 2)).to.eq('2 hours ago');
6466
expect(humanizeRelativeTime(-1000 * 60 * 60 * 24)).to.eq('yesterday');
6567
expect(humanizeRelativeTime(-1000 * 60 * 60 * 24 * 2)).to.eq('2 days ago');

0 commit comments

Comments
 (0)