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".
This commit is contained in:
@@ -54,12 +54,14 @@ describe('Time', () => {
|
||||
});
|
||||
|
||||
it('should return a humanized duration negative', () => {
|
||||
expect(humanizeRelativeTime(-1)).to.eq('1 minute ago');
|
||||
expect(humanizeRelativeTime(-1)).to.eq('this minute');
|
||||
expect(humanizeRelativeTime(-1000 * 60)).to.eq('1 minute ago');
|
||||
expect(humanizeRelativeTime(-1000 * 60 - 1)).to.eq('2 minutes ago');
|
||||
expect(humanizeRelativeTime(-1000 * 60 - 1)).to.eq('1 minute ago');
|
||||
expect(humanizeRelativeTime(-1000 * 60 * 2)).to.eq('2 minutes ago');
|
||||
expect(humanizeRelativeTime(-1000 * 60 * 2 - 1)).to.eq('3 minutes ago');
|
||||
expect(humanizeRelativeTime(-1000 * 60 * 2 - 1)).to.eq('2 minutes ago');
|
||||
expect(humanizeRelativeTime(-1000 * 60 * 3)).to.eq('3 minutes ago');
|
||||
expect(humanizeRelativeTime(-1000 * 60 * 60)).to.eq('1 hour ago');
|
||||
expect(humanizeRelativeTime(-1000 * 60 * 60 - 1)).to.eq('1 hour ago');
|
||||
expect(humanizeRelativeTime(-1000 * 60 * 60 * 2)).to.eq('2 hours ago');
|
||||
expect(humanizeRelativeTime(-1000 * 60 * 60 * 24)).to.eq('yesterday');
|
||||
expect(humanizeRelativeTime(-1000 * 60 * 60 * 24 * 2)).to.eq('2 days ago');
|
||||
|
||||
Reference in New Issue
Block a user