]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
[tests] relative time threshold doesn't work for multiple (#4913)
authorTimothy Z Searcy <timmyzsearcy@gmail.com>
Fri, 18 Jan 2019 03:08:52 +0000 (19:08 -0800)
committerKunal Marwaha <marwahaha@berkeley.edu>
Fri, 18 Jan 2019 03:08:52 +0000 (19:08 -0800)
* [bugfix] relative time threshold doesn't work for multiple

* return humanize to normal

src/test/moment/relative_time.js

index c2bbf6fa205f8f3ccb145ff3e36faeaad3808a46..f1ea491cb0f4d44ecfce860d491b9af38a6be707 100644 (file)
@@ -148,6 +148,16 @@ test('custom thresholds', function (assert) {
     a.subtract(1, 'months');
     assert.equal(a.fromNow(), 'a year ago', 'Above custom days to years threshold');
     moment.relativeTimeThreshold('M', 11);
+
+    // multiple thresholds
+    moment.relativeTimeThreshold('ss', 3);
+    a = moment();
+    a.subtract(4, 'seconds');
+    assert.equal(a.fromNow(), '4 seconds ago', 'Before setting s relative time threshold');
+    moment.relativeTimeThreshold('s', 59);
+    assert.equal(a.fromNow(), 'a few seconds ago', 'After setting s relative time threshold');
+    moment.relativeTimeThreshold('ss', 44);
+    moment.relativeTimeThreshold('s', 45);
 });
 
 test('custom rounding', function (assert) {