2024-04-26 20:34:16 +00:00
|
|
|
import {getTimeFromNow} from 'app/client/lib/timeUtils';
|
2022-08-18 21:08:39 +00:00
|
|
|
import {assert} from 'chai';
|
|
|
|
import moment from 'moment';
|
|
|
|
|
2024-04-26 20:34:16 +00:00
|
|
|
describe("timeUtils", function() {
|
2022-08-18 21:08:39 +00:00
|
|
|
describe("getTimeFromNow", function() {
|
|
|
|
it("should give good summary of time that just passed", function() {
|
|
|
|
const t = moment().subtract(10, 's');
|
|
|
|
assert.equal(getTimeFromNow(t.toISOString()), 'a few seconds ago');
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should gloss over times slightly in future", function() {
|
|
|
|
const t = moment().add(2, 's');
|
|
|
|
assert.equal(getTimeFromNow(t.toISOString()), 'a few seconds ago');
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should not gloss over times further in future", function() {
|
|
|
|
const t = moment().add(2, 'minutes');
|
|
|
|
assert.equal(getTimeFromNow(t.toISOString()), 'in 2 minutes');
|
|
|
|
});
|
2024-04-26 20:34:16 +00:00
|
|
|
});
|
2022-08-18 21:08:39 +00:00
|
|
|
});
|