FIX: times showing as < 1m instead of blank

This commit is contained in:
Neil Lalonde 2017-11-21 14:33:39 -05:00
parent 66e53f449a
commit 33feb62673
2 changed files with 4 additions and 0 deletions

View File

@ -130,6 +130,8 @@ function wrapAgo(dateStr) {
}
export function durationTiny(distance, ageOpts) {
if (typeof(distance) !== 'number') { return '&mdash;'; }
const dividedDistance = Math.round(distance / 60.0);
const distanceInMinutes = (dividedDistance < 1) ? 1 : dividedDistance;

View File

@ -214,6 +214,8 @@ QUnit.test("number", assert => {
});
QUnit.test("durationTiny", assert => {
assert.equal(durationTiny(), '&mdash;', "undefined is a dash");
assert.equal(durationTiny(null), '&mdash;', "null is a dash");
assert.equal(durationTiny(0), '< 1m', "0 seconds shows as < 1m");
assert.equal(durationTiny(59), '< 1m', "59 seconds shows as < 1m");
assert.equal(durationTiny(60), '1m', "60 seconds shows as 1m");