javascript-time-ago 2.6.1 → 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/bundle/javascript-time-ago.js +1 -1
- package/bundle/javascript-time-ago.js.map +1 -1
- package/bundle/javascript-time-ago.min.js +1 -1
- package/bundle/javascript-time-ago.min.js.map +1 -1
- package/commonjs/FullDateFormatter.test.js +11 -9
- package/commonjs/FullDateFormatter.test.js.map +1 -1
- package/commonjs/TimeAgo.js +8 -5
- package/commonjs/TimeAgo.js.map +1 -1
- package/commonjs/TimeAgo.test.js +237 -236
- package/commonjs/TimeAgo.test.js.map +1 -1
- package/commonjs/cache.test.js +8 -6
- package/commonjs/cache.test.js.map +1 -1
- package/commonjs/isStyleObject.test.js +21 -19
- package/commonjs/isStyleObject.test.js.map +1 -1
- package/commonjs/locale.test.js +16 -14
- package/commonjs/locale.test.js.map +1 -1
- package/commonjs/steps/approximate.test.js +26 -24
- package/commonjs/steps/approximate.test.js.map +1 -1
- package/commonjs/steps/getStep.test.js +20 -18
- package/commonjs/steps/getStep.test.js.map +1 -1
- package/commonjs/steps/getStepDenominator.test.js +9 -7
- package/commonjs/steps/getStepDenominator.test.js.map +1 -1
- package/commonjs/steps/getStepMinTime.test.js +9 -7
- package/commonjs/steps/getStepMinTime.test.js.map +1 -1
- package/commonjs/steps/getTimeToNextUpdate.test.js +56 -54
- package/commonjs/steps/getTimeToNextUpdate.test.js.map +1 -1
- package/commonjs/steps/getTimeToNextUpdateForUnit.test.js +20 -18
- package/commonjs/steps/getTimeToNextUpdateForUnit.test.js.map +1 -1
- package/commonjs/steps/helpers.test.js +6 -4
- package/commonjs/steps/helpers.test.js.map +1 -1
- package/commonjs/steps/renameLegacyProperties.test.js +12 -10
- package/commonjs/steps/renameLegacyProperties.test.js.map +1 -1
- package/commonjs/steps/round.test.js +27 -25
- package/commonjs/steps/round.test.js.map +1 -1
- package/commonjs/style/approximateTime.test.js +6 -5
- package/commonjs/style/approximateTime.test.js.map +1 -1
- package/commonjs/style/mini.test.js +62 -60
- package/commonjs/style/mini.test.js.map +1 -1
- package/commonjs/style/miniMinute.test.js +27 -25
- package/commonjs/style/miniMinute.test.js.map +1 -1
- package/commonjs/style/miniMinuteNow.test.js +27 -25
- package/commonjs/style/miniMinuteNow.test.js.map +1 -1
- package/commonjs/style/miniNow.test.js +27 -25
- package/commonjs/style/miniNow.test.js.map +1 -1
- package/commonjs/style/renameLegacyProperties.test.js +9 -7
- package/commonjs/style/renameLegacyProperties.test.js.map +1 -1
- package/commonjs/style/round.test.js +81 -79
- package/commonjs/style/round.test.js.map +1 -1
- package/commonjs/style/roundMinute.test.js +50 -48
- package/commonjs/style/roundMinute.test.js.map +1 -1
- package/commonjs/style/twitter.test.js +86 -84
- package/commonjs/style/twitter.test.js.map +1 -1
- package/commonjs/style/twitterFirstMinute.test.js +33 -31
- package/commonjs/style/twitterFirstMinute.test.js.map +1 -1
- package/commonjs/style/twitterMinute.test.js +32 -30
- package/commonjs/style/twitterMinute.test.js.map +1 -1
- package/commonjs/style/twitterMinuteNow.test.js +32 -30
- package/commonjs/style/twitterMinuteNow.test.js.map +1 -1
- package/commonjs/style/twitterNow.test.js +34 -32
- package/commonjs/style/twitterNow.test.js.map +1 -1
- package/index.d.ts +46 -7
- package/load-all-locales/index.cjs +15 -0
- package/load-all-locales/index.cjs.js +15 -0
- package/load-all-locales/index.js +30 -0
- package/locale/ak.json +8 -26
- package/locale/ak.json.js +8 -26
- package/locale/am.json +3 -3
- package/locale/am.json.js +3 -3
- package/locale/ba/package.json +16 -0
- package/locale/ba.json +159 -0
- package/locale/ba.json.d.ts +4 -0
- package/locale/ba.json.js +159 -0
- package/locale/be-tarask.json +4 -4
- package/locale/be-tarask.json.js +4 -4
- package/locale/be.json +4 -4
- package/locale/be.json.js +4 -4
- package/locale/bn.json +6 -6
- package/locale/bn.json.js +6 -6
- package/locale/bs.json +36 -30
- package/locale/bs.json.js +36 -30
- package/locale/bua/package.json +16 -0
- package/locale/bua.json +159 -0
- package/locale/bua.json.d.ts +4 -0
- package/locale/bua.json.js +159 -0
- package/locale/cv.json +134 -82
- package/locale/cv.json.js +134 -82
- package/locale/en-EE/package.json +16 -0
- package/locale/en-EE.json +219 -0
- package/locale/en-EE.json.d.ts +4 -0
- package/locale/en-EE.json.js +219 -0
- package/locale/en-GE/package.json +16 -0
- package/locale/en-GE.json +219 -0
- package/locale/en-GE.json.d.ts +4 -0
- package/locale/en-GE.json.js +219 -0
- package/locale/en-LT/package.json +16 -0
- package/locale/en-LT.json +219 -0
- package/locale/en-LT.json.d.ts +4 -0
- package/locale/en-LT.json.js +219 -0
- package/locale/en-LV/package.json +16 -0
- package/locale/en-LV.json +219 -0
- package/locale/en-LV.json.d.ts +4 -0
- package/locale/en-LV.json.js +219 -0
- package/locale/en-UA/package.json +16 -0
- package/locale/en-UA.json +219 -0
- package/locale/en-UA.json.d.ts +4 -0
- package/locale/en-UA.json.js +219 -0
- package/locale/es-MX.json +2 -8
- package/locale/es-MX.json.js +2 -8
- package/locale/fr-CA.json +4 -4
- package/locale/fr-CA.json.js +4 -4
- package/locale/fr.json +4 -4
- package/locale/fr.json.js +4 -4
- package/locale/he.json +74 -86
- package/locale/he.json.js +74 -86
- package/locale/ht.json +4 -4
- package/locale/ht.json.js +4 -4
- package/locale/ie.json +15 -9
- package/locale/ie.json.js +15 -9
- package/locale/kk-Arab/package.json +16 -0
- package/locale/kk-Arab.json +159 -0
- package/locale/kk-Arab.json.d.ts +4 -0
- package/locale/kk-Arab.json.js +159 -0
- package/locale/kok-Latn.json +138 -39
- package/locale/kok-Latn.json.js +138 -39
- package/locale/kok.json +169 -64
- package/locale/kok.json.js +169 -64
- package/locale/ku.json +166 -73
- package/locale/ku.json.js +166 -73
- package/locale/mk.json +20 -20
- package/locale/mk.json.js +20 -20
- package/locale/nso/package.json +16 -0
- package/locale/nso.json +159 -0
- package/locale/nso.json.d.ts +4 -0
- package/locale/nso.json.js +159 -0
- package/locale/rm.json +151 -85
- package/locale/rm.json.js +151 -85
- package/locale/ro.json +4 -2
- package/locale/ro.json.js +4 -2
- package/locale/rw/package.json +16 -0
- package/locale/rw.json +159 -0
- package/locale/rw.json.d.ts +4 -0
- package/locale/rw.json.js +159 -0
- package/locale/scn/package.json +16 -0
- package/locale/scn.json +249 -0
- package/locale/scn.json.d.ts +4 -0
- package/locale/scn.json.js +249 -0
- package/locale/sd-Deva/package.json +16 -0
- package/locale/sd-Deva.json +159 -0
- package/locale/sd-Deva.json.d.ts +4 -0
- package/locale/sd-Deva.json.js +159 -0
- package/locale/sd.json +77 -20
- package/locale/sd.json.js +77 -20
- package/locale/shn/package.json +16 -0
- package/locale/shn.json +159 -0
- package/locale/shn.json.d.ts +4 -0
- package/locale/shn.json.js +159 -0
- package/locale/sv.json +3 -3
- package/locale/sv.json.js +3 -3
- package/locale/syr.json +27 -27
- package/locale/syr.json.js +27 -27
- package/locale/ta.json +15 -9
- package/locale/ta.json.js +15 -9
- package/locale/tn.json +27 -27
- package/locale/tn.json.js +27 -27
- package/locale/tok/package.json +16 -0
- package/locale/tok.json +159 -0
- package/locale/tok.json.d.ts +4 -0
- package/locale/tok.json.js +159 -0
- package/locale/tyv/package.json +16 -0
- package/locale/tyv.json +159 -0
- package/locale/tyv.json.d.ts +4 -0
- package/locale/tyv.json.js +159 -0
- package/locale/xh.json +18 -18
- package/locale/xh.json.js +18 -18
- package/modules/FullDateFormatter.test.js +2 -0
- package/modules/FullDateFormatter.test.js.map +1 -1
- package/modules/TimeAgo.js +8 -5
- package/modules/TimeAgo.js.map +1 -1
- package/modules/TimeAgo.test.js +190 -189
- package/modules/TimeAgo.test.js.map +1 -1
- package/modules/cache.test.js +2 -0
- package/modules/cache.test.js.map +1 -1
- package/modules/isStyleObject.test.js +19 -17
- package/modules/isStyleObject.test.js.map +1 -1
- package/modules/locale.test.js +12 -10
- package/modules/locale.test.js.map +1 -1
- package/modules/steps/approximate.test.js +2 -0
- package/modules/steps/approximate.test.js.map +1 -1
- package/modules/steps/getStep.test.js +7 -5
- package/modules/steps/getStep.test.js.map +1 -1
- package/modules/steps/getStepDenominator.test.js +6 -4
- package/modules/steps/getStepDenominator.test.js.map +1 -1
- package/modules/steps/getStepMinTime.test.js +6 -4
- package/modules/steps/getStepMinTime.test.js.map +1 -1
- package/modules/steps/getTimeToNextUpdate.test.js +36 -34
- package/modules/steps/getTimeToNextUpdate.test.js.map +1 -1
- package/modules/steps/getTimeToNextUpdateForUnit.test.js +12 -10
- package/modules/steps/getTimeToNextUpdateForUnit.test.js.map +1 -1
- package/modules/steps/helpers.test.js +4 -2
- package/modules/steps/helpers.test.js.map +1 -1
- package/modules/steps/renameLegacyProperties.test.js +8 -6
- package/modules/steps/renameLegacyProperties.test.js.map +1 -1
- package/modules/steps/round.test.js +2 -0
- package/modules/steps/round.test.js.map +1 -1
- package/modules/style/approximateTime.test.js +3 -2
- package/modules/style/approximateTime.test.js.map +1 -1
- package/modules/style/mini.test.js +58 -56
- package/modules/style/mini.test.js.map +1 -1
- package/modules/style/miniMinute.test.js +25 -23
- package/modules/style/miniMinute.test.js.map +1 -1
- package/modules/style/miniMinuteNow.test.js +25 -23
- package/modules/style/miniMinuteNow.test.js.map +1 -1
- package/modules/style/miniNow.test.js +25 -23
- package/modules/style/miniNow.test.js.map +1 -1
- package/modules/style/renameLegacyProperties.test.js +6 -4
- package/modules/style/renameLegacyProperties.test.js.map +1 -1
- package/modules/style/round.test.js +76 -74
- package/modules/style/round.test.js.map +1 -1
- package/modules/style/roundMinute.test.js +47 -45
- package/modules/style/roundMinute.test.js.map +1 -1
- package/modules/style/twitter.test.js +72 -70
- package/modules/style/twitter.test.js.map +1 -1
- package/modules/style/twitterFirstMinute.test.js +29 -27
- package/modules/style/twitterFirstMinute.test.js.map +1 -1
- package/modules/style/twitterMinute.test.js +29 -27
- package/modules/style/twitterMinute.test.js.map +1 -1
- package/modules/style/twitterMinuteNow.test.js +29 -27
- package/modules/style/twitterMinuteNow.test.js.map +1 -1
- package/modules/style/twitterNow.test.js +31 -29
- package/modules/style/twitterNow.test.js.map +1 -1
- package/package.json +129 -8
- /package/{bin → scripts}/create-commonjs-package-json.js +0 -0
- /package/{bin → scripts}/generate-load-all-locales.js +0 -0
- /package/{bin → scripts}/generate-locale-messages.js +0 -0
package/commonjs/TimeAgo.test.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _mocha = require("mocha");
|
|
4
|
+
var _chai = require("chai");
|
|
3
5
|
var _TimeAgo = _interopRequireDefault(require("./TimeAgo.js"));
|
|
4
|
-
var _LocaleDataStore = require("./LocaleDataStore.js");
|
|
5
6
|
var _en = _interopRequireDefault(require("../locale/en.json"));
|
|
6
7
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
7
8
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
@@ -12,22 +13,22 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
12
13
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } // Load locale specific relative date/time messages
|
|
13
14
|
// Just so this function code is covered.
|
|
14
15
|
_TimeAgo["default"].setDefaultLocale('en');
|
|
15
|
-
describe("javascript-time-ago", function () {
|
|
16
|
-
it('should default to "round-minute" style', function () {
|
|
16
|
+
(0, _mocha.describe)("javascript-time-ago", function () {
|
|
17
|
+
(0, _mocha.it)('should default to "round-minute" style', function () {
|
|
17
18
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
18
|
-
timeAgo.format(Date.now()).
|
|
19
|
-
timeAgo.format(Date.now() + 20 * 1000).
|
|
20
|
-
timeAgo.format(Date.now() + 1 * 60 * 1000).
|
|
21
|
-
timeAgo.format(Date.now() + 4 * 60 * 1000).
|
|
19
|
+
(0, _chai.expect)(timeAgo.format(Date.now())).to.equal('just now');
|
|
20
|
+
(0, _chai.expect)(timeAgo.format(Date.now() + 20 * 1000)).to.equal('in a moment');
|
|
21
|
+
(0, _chai.expect)(timeAgo.format(Date.now() + 1 * 60 * 1000)).to.equal('in 1 minute');
|
|
22
|
+
(0, _chai.expect)(timeAgo.format(Date.now() + 4 * 60 * 1000)).to.equal('in 4 minutes');
|
|
22
23
|
});
|
|
23
|
-
it('should tell `options` argument from `style` argument', function () {
|
|
24
|
+
(0, _mocha.it)('should tell `options` argument from `style` argument', function () {
|
|
24
25
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
25
|
-
timeAgo.format(Date.now(), 'mini-now').
|
|
26
|
-
timeAgo.format(0, {
|
|
26
|
+
(0, _chai.expect)(timeAgo.format(Date.now(), 'mini-now')).to.equal('now');
|
|
27
|
+
(0, _chai.expect)(timeAgo.format(0, {
|
|
27
28
|
future: true,
|
|
28
29
|
now: 0
|
|
29
|
-
}).
|
|
30
|
-
timeAgo.format(0, {
|
|
30
|
+
})).to.equal('in a moment');
|
|
31
|
+
(0, _chai.expect)(timeAgo.format(0, {
|
|
31
32
|
labels: 'mini',
|
|
32
33
|
steps: [{
|
|
33
34
|
formatAs: 'now'
|
|
@@ -37,8 +38,8 @@ describe("javascript-time-ago", function () {
|
|
|
37
38
|
}, {
|
|
38
39
|
future: true,
|
|
39
40
|
now: 0
|
|
40
|
-
}).
|
|
41
|
-
timeAgo.format(0, {
|
|
41
|
+
})).to.equal('now');
|
|
42
|
+
(0, _chai.expect)(timeAgo.format(0, {
|
|
42
43
|
labels: ['mini'],
|
|
43
44
|
steps: [{
|
|
44
45
|
formatAs: 'now'
|
|
@@ -48,95 +49,95 @@ describe("javascript-time-ago", function () {
|
|
|
48
49
|
}, {
|
|
49
50
|
future: true,
|
|
50
51
|
now: 0
|
|
51
|
-
}).
|
|
52
|
+
})).to.equal('now');
|
|
52
53
|
// `flavour` is a legacy name of `labels` property.
|
|
53
|
-
timeAgo.format(0, {
|
|
54
|
+
(0, _chai.expect)(timeAgo.format(0, {
|
|
54
55
|
flavour: 'mini'
|
|
55
56
|
}, {
|
|
56
57
|
future: true,
|
|
57
58
|
now: 0
|
|
58
|
-
}).
|
|
59
|
-
timeAgo.format(0, {
|
|
59
|
+
})).to.equal('now');
|
|
60
|
+
(0, _chai.expect)(timeAgo.format(0, {
|
|
60
61
|
flavour: ['mini']
|
|
61
62
|
}, {
|
|
62
63
|
future: true,
|
|
63
64
|
now: 0
|
|
64
|
-
}).
|
|
65
|
-
timeAgo.format(0, {
|
|
65
|
+
})).to.equal('now');
|
|
66
|
+
(0, _chai.expect)(timeAgo.format(0, {
|
|
66
67
|
steps: [{
|
|
67
68
|
formatAs: 'minute'
|
|
68
69
|
}]
|
|
69
70
|
}, {
|
|
70
71
|
future: true,
|
|
71
72
|
now: 0
|
|
72
|
-
}).
|
|
73
|
+
})).to.equal('in 0 minutes');
|
|
73
74
|
// `gradation` is a legacy name of `steps` property.
|
|
74
|
-
timeAgo.format(0, {
|
|
75
|
+
(0, _chai.expect)(timeAgo.format(0, {
|
|
75
76
|
gradation: [{
|
|
76
77
|
formatAs: 'minute'
|
|
77
78
|
}]
|
|
78
79
|
}, {
|
|
79
80
|
future: true,
|
|
80
81
|
now: 0
|
|
81
|
-
}).
|
|
82
|
+
})).to.equal('in 0 minutes');
|
|
82
83
|
});
|
|
83
|
-
it('should try various label types until an appropriate one is found', function () {
|
|
84
|
+
(0, _mocha.it)('should try various label types until an appropriate one is found', function () {
|
|
84
85
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
85
|
-
timeAgo.format(Date.now(), {
|
|
86
|
+
(0, _chai.expect)(timeAgo.format(Date.now(), {
|
|
86
87
|
labels: ['exotic', 'short']
|
|
87
|
-
}).
|
|
88
|
+
})).to.equal('just now');
|
|
88
89
|
});
|
|
89
|
-
it('should support the legacy name "flavour" of "labels"', function () {
|
|
90
|
+
(0, _mocha.it)('should support the legacy name "flavour" of "labels"', function () {
|
|
90
91
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
91
|
-
timeAgo.format(Date.now(), {
|
|
92
|
+
(0, _chai.expect)(timeAgo.format(Date.now(), {
|
|
92
93
|
labels: ['exotic', 'short']
|
|
93
|
-
}).
|
|
94
|
+
})).to.equal('just now');
|
|
94
95
|
});
|
|
95
|
-
it('should fallback to "second.current" for "now" when "now" is not defined', function () {
|
|
96
|
+
(0, _mocha.it)('should fallback to "second.current" for "now" when "now" is not defined', function () {
|
|
96
97
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
97
98
|
var englishNow = _en["default"].now;
|
|
98
99
|
delete _en["default"].now;
|
|
99
100
|
_TimeAgo["default"].addLocale(_en["default"]);
|
|
100
101
|
_en["default"].now = undefined;
|
|
101
|
-
timeAgo.format(Date.now(), {
|
|
102
|
+
(0, _chai.expect)(timeAgo.format(Date.now(), {
|
|
102
103
|
labels: 'long'
|
|
103
|
-
}).
|
|
104
|
+
})).to.equal('now');
|
|
104
105
|
_en["default"].now = englishNow;
|
|
105
|
-
timeAgo.format(Date.now(), {
|
|
106
|
+
(0, _chai.expect)(timeAgo.format(Date.now(), {
|
|
106
107
|
labels: 'long'
|
|
107
|
-
}).
|
|
108
|
+
})).to.equal('just now');
|
|
108
109
|
});
|
|
109
|
-
it('should not use Intl.NumberFormat if it is not available', function () {
|
|
110
|
+
(0, _mocha.it)('should not use Intl.NumberFormat if it is not available', function () {
|
|
110
111
|
var NumberFormat = Intl.NumberFormat;
|
|
111
112
|
delete Intl.NumberFormat;
|
|
112
113
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
113
|
-
timeAgo.format(Date.now() + 60 * 1000, {
|
|
114
|
+
(0, _chai.expect)(timeAgo.format(Date.now() + 60 * 1000, {
|
|
114
115
|
labels: 'long-time'
|
|
115
|
-
}).
|
|
116
|
+
})).to.equal('1 minute');
|
|
116
117
|
Intl.NumberFormat = NumberFormat;
|
|
117
118
|
});
|
|
118
|
-
it('should work when "past"/"future" messages are same for all quantifiers', function () {
|
|
119
|
+
(0, _mocha.it)('should work when "past"/"future" messages are same for all quantifiers', function () {
|
|
119
120
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
120
|
-
timeAgo.format(Date.now() + 365 * 24 * 60 * 60 * 1000, {
|
|
121
|
+
(0, _chai.expect)(timeAgo.format(Date.now() + 365 * 24 * 60 * 60 * 1000, {
|
|
121
122
|
labels: 'short'
|
|
122
|
-
}).
|
|
123
|
+
})).to.equal('in 1 yr.');
|
|
123
124
|
});
|
|
124
|
-
it('should work when "now" is a string (does not differentiate between "past" and "future")', function () {
|
|
125
|
+
(0, _mocha.it)('should work when "now" is a string (does not differentiate between "past" and "future")', function () {
|
|
125
126
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
126
127
|
var englishNow = _en["default"].now;
|
|
127
128
|
_en["default"].now = {
|
|
128
129
|
now: 'now'
|
|
129
130
|
};
|
|
130
131
|
_TimeAgo["default"].addLocale(_en["default"]);
|
|
131
|
-
timeAgo.format(Date.now(), {
|
|
132
|
+
(0, _chai.expect)(timeAgo.format(Date.now(), {
|
|
132
133
|
labels: 'long'
|
|
133
|
-
}).
|
|
134
|
+
})).to.equal('now');
|
|
134
135
|
_en["default"].now = englishNow;
|
|
135
|
-
timeAgo.format(Date.now(), {
|
|
136
|
+
(0, _chai.expect)(timeAgo.format(Date.now(), {
|
|
136
137
|
labels: 'long'
|
|
137
|
-
}).
|
|
138
|
+
})).to.equal('just now');
|
|
138
139
|
});
|
|
139
|
-
it('should work when a unit has formatting rules for "past" and "future" which are strings (style: not "long", not "short", not "narrow")', function () {
|
|
140
|
+
(0, _mocha.it)('should work when a unit has formatting rules for "past" and "future" which are strings (style: not "long", not "short", not "narrow")', function () {
|
|
140
141
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
141
142
|
var englishLongTimeMinute = _en["default"]['long-time'].minute;
|
|
142
143
|
_en["default"]['long-time'].minute = {
|
|
@@ -145,96 +146,96 @@ describe("javascript-time-ago", function () {
|
|
|
145
146
|
};
|
|
146
147
|
_TimeAgo["default"].addLocale(_en["default"]);
|
|
147
148
|
// Past.
|
|
148
|
-
timeAgo.format(Date.now() - 60 * 1000, {
|
|
149
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 60 * 1000, {
|
|
149
150
|
labels: 'long-time'
|
|
150
|
-
}).
|
|
151
|
+
})).to.equal('1 minute(s) ago');
|
|
151
152
|
// Future (covers an "else" branch).
|
|
152
|
-
timeAgo.format(Date.now() + 60 * 1000, {
|
|
153
|
+
(0, _chai.expect)(timeAgo.format(Date.now() + 60 * 1000, {
|
|
153
154
|
labels: 'long-time'
|
|
154
|
-
}).
|
|
155
|
+
})).to.equal('in 1 minute(s)');
|
|
155
156
|
// Undo.
|
|
156
157
|
_en["default"]['long-time'].minute = englishLongTimeMinute;
|
|
157
|
-
timeAgo.format(Date.now() - 60 * 1000, {
|
|
158
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 60 * 1000, {
|
|
158
159
|
labels: 'long-time'
|
|
159
|
-
}).
|
|
160
|
+
})).to.equal('1 minute');
|
|
160
161
|
});
|
|
161
|
-
it("should format \"now\" for \"past\" time", function () {
|
|
162
|
+
(0, _mocha.it)("should format \"now\" for \"past\" time", function () {
|
|
162
163
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
163
|
-
timeAgo.format(Date.now() + 10, {
|
|
164
|
+
(0, _chai.expect)(timeAgo.format(Date.now() + 10, {
|
|
164
165
|
labels: ['long']
|
|
165
|
-
}).
|
|
166
|
+
})).to.equal('in a moment');
|
|
166
167
|
});
|
|
167
|
-
it('should accept a string style name argument', function () {
|
|
168
|
+
(0, _mocha.it)('should accept a string style name argument', function () {
|
|
168
169
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
169
170
|
// "mini".
|
|
170
|
-
timeAgo.format(Date.now() - 0 * 1000, 'mini').
|
|
171
|
-
timeAgo.format(Date.now() - 1 * 1000, 'mini').
|
|
171
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 0 * 1000, 'mini')).to.equal('0s');
|
|
172
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 1 * 1000, 'mini')).to.equal('1s');
|
|
172
173
|
// "mini-now".
|
|
173
|
-
timeAgo.format(Date.now() - 0 * 1000, 'mini-now').
|
|
174
|
-
timeAgo.format(Date.now() - 1 * 1000, 'mini-now').
|
|
174
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 0 * 1000, 'mini-now')).to.equal('now');
|
|
175
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 1 * 1000, 'mini-now')).to.equal('1s');
|
|
175
176
|
// "mini-minute-now".
|
|
176
|
-
timeAgo.format(Date.now() - 29 * 1000, 'mini-minute-now').
|
|
177
|
-
timeAgo.format(Date.now() - 60 * 1000, 'mini-minute-now').
|
|
177
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 29 * 1000, 'mini-minute-now')).to.equal('now');
|
|
178
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 60 * 1000, 'mini-minute-now')).to.equal('1m');
|
|
178
179
|
// "mini-minute".
|
|
179
|
-
timeAgo.format(Date.now() - 29 * 1000, 'mini-minute').
|
|
180
|
-
timeAgo.format(Date.now() - 60 * 1000, 'mini-minute').
|
|
180
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 29 * 1000, 'mini-minute')).to.equal('0m');
|
|
181
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 60 * 1000, 'mini-minute')).to.equal('1m');
|
|
181
182
|
// "twitter".
|
|
182
|
-
timeAgo.format(Date.now() - 0 * 1000, 'twitter').
|
|
183
|
-
timeAgo.format(Date.now() - 1 * 1000, 'twitter').
|
|
183
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 0 * 1000, 'twitter')).to.equal('0s');
|
|
184
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 1 * 1000, 'twitter')).to.equal('1s');
|
|
184
185
|
// "twitter-now".
|
|
185
|
-
timeAgo.format(Date.now() - 0 * 1000, 'twitter-now').
|
|
186
|
-
timeAgo.format(Date.now() - 1 * 1000, 'twitter-now').
|
|
186
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 0 * 1000, 'twitter-now')).to.equal('now');
|
|
187
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 1 * 1000, 'twitter-now')).to.equal('1s');
|
|
187
188
|
// "twitter-minute-now".
|
|
188
|
-
timeAgo.format(Date.now() - 29 * 1000, 'twitter-minute-now').
|
|
189
|
-
timeAgo.format(Date.now() - 60 * 1000, 'twitter-minute-now').
|
|
189
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 29 * 1000, 'twitter-minute-now')).to.equal('now');
|
|
190
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 60 * 1000, 'twitter-minute-now')).to.equal('1m');
|
|
190
191
|
// "twitter-minute".
|
|
191
|
-
timeAgo.format(Date.now() - 29 * 1000, 'twitter-minute').
|
|
192
|
-
timeAgo.format(Date.now() - 60 * 1000, 'twitter-minute').
|
|
192
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 29 * 1000, 'twitter-minute')).to.equal('0m');
|
|
193
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 60 * 1000, 'twitter-minute')).to.equal('1m');
|
|
193
194
|
// "twitter-first-minute".
|
|
194
|
-
timeAgo.format(Date.now() - 29 * 1000, 'twitter-first-minute').
|
|
195
|
-
timeAgo.format(Date.now() - 60 * 1000, 'twitter-first-minute').
|
|
195
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 29 * 1000, 'twitter-first-minute')).to.equal('');
|
|
196
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 60 * 1000, 'twitter-first-minute')).to.equal('1m');
|
|
196
197
|
// "approximate".
|
|
197
|
-
timeAgo.format(Date.now() - 45 * 1000, 'approximate').
|
|
198
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 45 * 1000, 'approximate')).to.equal('just now');
|
|
198
199
|
// "convenient" style was renamed to "approximate".
|
|
199
|
-
timeAgo.format(Date.now() - 45 * 1000, 'convenient').
|
|
200
|
-
timeAgo.format(Date.now() - 45 * 1000, 'round').
|
|
200
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 45 * 1000, 'convenient')).to.equal('just now');
|
|
201
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 45 * 1000, 'round')).to.equal('45 seconds ago');
|
|
201
202
|
// "default" style was renamed to "round".
|
|
202
|
-
timeAgo.format(Date.now() - 45 * 1000, 'default').
|
|
203
|
-
timeAgo.format(Date.now() - 29 * 1000, 'round-minute').
|
|
203
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 45 * 1000, 'default')).to.equal('45 seconds ago');
|
|
204
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 29 * 1000, 'round-minute')).to.equal('just now');
|
|
204
205
|
// "time" style was renamed to "approximate-time".
|
|
205
|
-
timeAgo.format(Date.now() - 2 * 60 * 1000, 'time').
|
|
206
|
-
timeAgo.format(Date.now() - 2 * 60 * 1000, 'approximate-time').
|
|
207
|
-
timeAgo.format(Date.now(), 'exotic').
|
|
206
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 2 * 60 * 1000, 'time')).to.equal('2 minutes');
|
|
207
|
+
(0, _chai.expect)(timeAgo.format(Date.now() - 2 * 60 * 1000, 'approximate-time')).to.equal('2 minutes');
|
|
208
|
+
(0, _chai.expect)(timeAgo.format(Date.now(), 'exotic')).to.equal('just now');
|
|
208
209
|
});
|
|
209
|
-
it('should accept empty constructor parameters', function () {
|
|
210
|
+
(0, _mocha.it)('should accept empty constructor parameters', function () {
|
|
210
211
|
var timeAgo = new _TimeAgo["default"]();
|
|
211
|
-
timeAgo.format(new Date()).
|
|
212
|
+
(0, _chai.expect)(timeAgo.format(new Date())).to.equal('just now');
|
|
212
213
|
});
|
|
213
|
-
it('should accept "mocked" Dates when testing', function () {
|
|
214
|
+
(0, _mocha.it)('should accept "mocked" Dates when testing', function () {
|
|
214
215
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
215
216
|
var mockedDate = {
|
|
216
217
|
getTime: function getTime() {
|
|
217
218
|
return Date.now();
|
|
218
219
|
}
|
|
219
220
|
};
|
|
220
|
-
timeAgo.format(mockedDate).
|
|
221
|
+
(0, _chai.expect)(timeAgo.format(mockedDate)).to.equal('just now');
|
|
221
222
|
});
|
|
222
|
-
it('should not accept anything but Dates and timestamps', function () {
|
|
223
|
+
(0, _mocha.it)('should not accept anything but Dates and timestamps', function () {
|
|
223
224
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
224
225
|
var thrower = function thrower() {
|
|
225
226
|
return timeAgo.format('Jan 14, 2017');
|
|
226
227
|
};
|
|
227
|
-
thrower.
|
|
228
|
+
(0, _chai.expect)(thrower).to["throw"]('Unsupported relative time formatter input: string, Jan 14, 2017');
|
|
228
229
|
});
|
|
229
|
-
it('should return an empty string if the specified units are not available in locale data', function () {
|
|
230
|
+
(0, _mocha.it)('should return an empty string if the specified units are not available in locale data', function () {
|
|
230
231
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
231
|
-
timeAgo.format(Date.now(), {
|
|
232
|
+
(0, _chai.expect)(timeAgo.format(Date.now(), {
|
|
232
233
|
units: ['femtosecond']
|
|
233
|
-
}).
|
|
234
|
+
})).to.equal('');
|
|
234
235
|
});
|
|
235
|
-
it('should format for a style with "custom" function', function () {
|
|
236
|
+
(0, _mocha.it)('should format for a style with "custom" function', function () {
|
|
236
237
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
237
|
-
timeAgo.format(Date.now(), {
|
|
238
|
+
(0, _chai.expect)(timeAgo.format(Date.now(), {
|
|
238
239
|
// `custom` returns a string
|
|
239
240
|
custom: function custom(_ref) {
|
|
240
241
|
var now = _ref.now,
|
|
@@ -243,8 +244,8 @@ describe("javascript-time-ago", function () {
|
|
|
243
244
|
locale = _ref.locale;
|
|
244
245
|
return locale;
|
|
245
246
|
}
|
|
246
|
-
}).
|
|
247
|
-
timeAgo.format(Date.now(), {
|
|
247
|
+
})).to.equal('en');
|
|
248
|
+
(0, _chai.expect)(timeAgo.format(Date.now(), {
|
|
248
249
|
// `custom` returns `undefined`
|
|
249
250
|
custom: function custom(_ref2) {
|
|
250
251
|
var now = _ref2.now,
|
|
@@ -253,11 +254,11 @@ describe("javascript-time-ago", function () {
|
|
|
253
254
|
locale = _ref2.locale;
|
|
254
255
|
return;
|
|
255
256
|
}
|
|
256
|
-
}).
|
|
257
|
+
})).to.equal('just now');
|
|
257
258
|
});
|
|
258
|
-
it('should throw an error when formating for a style with "custom" function and `getTimeToNextUpdate: true` parameter is passed', function () {
|
|
259
|
+
(0, _mocha.it)('should throw an error when formating for a style with "custom" function and `getTimeToNextUpdate: true` parameter is passed', function () {
|
|
259
260
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
260
|
-
expect(function () {
|
|
261
|
+
(0, _chai.expect)(function () {
|
|
261
262
|
timeAgo.format(Date.now(), {
|
|
262
263
|
// `custom` returns a string.
|
|
263
264
|
custom: function custom(_ref3) {
|
|
@@ -272,16 +273,16 @@ describe("javascript-time-ago", function () {
|
|
|
272
273
|
});
|
|
273
274
|
}).to["throw"]('not supported');
|
|
274
275
|
});
|
|
275
|
-
it('should format future dates', function () {
|
|
276
|
-
new _TimeAgo["default"]('en').format(Date.now() + 60 * 60 * 1000).
|
|
277
|
-
new _TimeAgo["default"]('ru').format(Date.now() + 60 * 1000).
|
|
276
|
+
(0, _mocha.it)('should format future dates', function () {
|
|
277
|
+
(0, _chai.expect)(new _TimeAgo["default"]('en').format(Date.now() + 60 * 60 * 1000)).to.equal('in 1 hour');
|
|
278
|
+
(0, _chai.expect)(new _TimeAgo["default"]('ru').format(Date.now() + 60 * 1000)).to.equal('через 1 минуту');
|
|
278
279
|
});
|
|
279
|
-
it('should accept "future" option', function () {
|
|
280
|
+
(0, _mocha.it)('should accept "future" option', function () {
|
|
280
281
|
// "now" unit.
|
|
281
|
-
new _TimeAgo["default"]('en').format(Date.now()).
|
|
282
|
-
new _TimeAgo["default"]('en').format(Date.now(), 'approximate', {
|
|
282
|
+
(0, _chai.expect)(new _TimeAgo["default"]('en').format(Date.now())).to.equal('just now');
|
|
283
|
+
(0, _chai.expect)(new _TimeAgo["default"]('en').format(Date.now(), 'approximate', {
|
|
283
284
|
future: true
|
|
284
|
-
}).
|
|
285
|
+
})).to.equal('in a moment');
|
|
285
286
|
|
|
286
287
|
// Non-"now" unit, "long" style.
|
|
287
288
|
// const style = {
|
|
@@ -291,8 +292,8 @@ describe("javascript-time-ago", function () {
|
|
|
291
292
|
// }],
|
|
292
293
|
// labels: 'long'
|
|
293
294
|
// }
|
|
294
|
-
// new TimeAgo('en').format(Date.now(), style).
|
|
295
|
-
// new TimeAgo('en').format(Date.now(), style, { future: true }).
|
|
295
|
+
// expect(new TimeAgo('en').format(Date.now(), style)).to.equal('0 seconds ago')
|
|
296
|
+
// expect(new TimeAgo('en').format(Date.now(), style, { future: true })).to.equal('in 0 seconds')
|
|
296
297
|
|
|
297
298
|
// Non-"now" unit, "mini" style.
|
|
298
299
|
var style2 = {
|
|
@@ -301,12 +302,12 @@ describe("javascript-time-ago", function () {
|
|
|
301
302
|
}],
|
|
302
303
|
labels: 'mini'
|
|
303
304
|
};
|
|
304
|
-
new _TimeAgo["default"]('ru').format(Date.now() - 5 * 365 * 24 * 60 * 60 * 1000, style2).
|
|
305
|
-
new _TimeAgo["default"]('ru').format(Date.now() - 5 * 365 * 24 * 60 * 60 * 1000, style2, {
|
|
305
|
+
(0, _chai.expect)(new _TimeAgo["default"]('ru').format(Date.now() - 5 * 365 * 24 * 60 * 60 * 1000, style2)).to.equal('5 л');
|
|
306
|
+
(0, _chai.expect)(new _TimeAgo["default"]('ru').format(Date.now() - 5 * 365 * 24 * 60 * 60 * 1000, style2, {
|
|
306
307
|
future: true
|
|
307
|
-
}).
|
|
308
|
+
})).to.equal('5 л');
|
|
308
309
|
});
|
|
309
|
-
it('should support the legacy properties: "gradation", "flavour", "factor", "unit", "\'tiny\'" labels style', function () {
|
|
310
|
+
(0, _mocha.it)('should support the legacy properties: "gradation", "flavour", "factor", "unit", "\'tiny\'" labels style', function () {
|
|
310
311
|
// Non-"now" unit, "tiny" style.
|
|
311
312
|
var style = {
|
|
312
313
|
gradation: [{
|
|
@@ -315,34 +316,34 @@ describe("javascript-time-ago", function () {
|
|
|
315
316
|
}],
|
|
316
317
|
flavour: 'tiny'
|
|
317
318
|
};
|
|
318
|
-
new _TimeAgo["default"]('ru').format(Date.now() - 10 * 1000, style).
|
|
319
|
-
new _TimeAgo["default"]('ru').format(Date.now() - 10 * 1000, style, {
|
|
319
|
+
(0, _chai.expect)(new _TimeAgo["default"]('ru').format(Date.now() - 10 * 1000, style)).to.equal('2 г');
|
|
320
|
+
(0, _chai.expect)(new _TimeAgo["default"]('ru').format(Date.now() - 10 * 1000, style, {
|
|
320
321
|
future: true
|
|
321
|
-
}).
|
|
322
|
+
})).to.equal('2 г');
|
|
322
323
|
});
|
|
323
|
-
it('should have generated missing quantifier functions for locales that do not have it in CLDR data', function () {
|
|
324
|
-
new _TimeAgo["default"]('ccp').format(Date.now() + 60 * 1000).
|
|
324
|
+
(0, _mocha.it)('should have generated missing quantifier functions for locales that do not have it in CLDR data', function () {
|
|
325
|
+
(0, _chai.expect)(new _TimeAgo["default"]('ccp').format(Date.now() + 60 * 1000)).to.include(' 𑄟𑄨𑄚𑄨𑄘𑄬');
|
|
325
326
|
});
|
|
326
|
-
it('should throw for non-existing locales', function () {
|
|
327
|
-
(function () {
|
|
327
|
+
(0, _mocha.it)('should throw for non-existing locales', function () {
|
|
328
|
+
(0, _chai.expect)(function () {
|
|
328
329
|
return _TimeAgo["default"].addLocale();
|
|
329
|
-
}).
|
|
330
|
+
}).to["throw"]('No locale data passed');
|
|
330
331
|
});
|
|
331
|
-
it('should choose "future" variant of a label for `0` if "future: true" option is passed', function () {
|
|
332
|
+
(0, _mocha.it)('should choose "future" variant of a label for `0` if "future: true" option is passed', function () {
|
|
332
333
|
_TimeAgo["default"].addLocale(_en["default"]);
|
|
333
334
|
var secondLabels = _en["default"]['mini'].second;
|
|
334
335
|
_en["default"]['mini'].second = {
|
|
335
336
|
past: '{0} seconds ago',
|
|
336
337
|
future: 'in {0} seconds'
|
|
337
338
|
};
|
|
338
|
-
new _TimeAgo["default"]('en').format(Date.now(), {
|
|
339
|
+
(0, _chai.expect)(new _TimeAgo["default"]('en').format(Date.now(), {
|
|
339
340
|
steps: [{
|
|
340
341
|
unit: 'second'
|
|
341
342
|
}],
|
|
342
343
|
// Uses "mini" labels so that it doesn't use `Intl.RelativeTimeFormat`.
|
|
343
344
|
labels: 'mini'
|
|
344
|
-
}).
|
|
345
|
-
new _TimeAgo["default"]('en').format(Date.now(), {
|
|
345
|
+
})).to.equal('0 seconds ago');
|
|
346
|
+
(0, _chai.expect)(new _TimeAgo["default"]('en').format(Date.now(), {
|
|
346
347
|
steps: [{
|
|
347
348
|
unit: 'second'
|
|
348
349
|
}],
|
|
@@ -350,17 +351,17 @@ describe("javascript-time-ago", function () {
|
|
|
350
351
|
labels: 'mini'
|
|
351
352
|
}, {
|
|
352
353
|
future: true
|
|
353
|
-
}).
|
|
354
|
+
})).to.equal('in 0 seconds');
|
|
354
355
|
_en["default"]['mini'].second = secondLabels;
|
|
355
356
|
});
|
|
356
|
-
it('should refresh the label when `refresh` parameter is passed', function () {
|
|
357
|
+
(0, _mocha.it)('should refresh the label when `refresh` parameter is passed', function () {
|
|
357
358
|
var refreshedTimes = 0;
|
|
358
359
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
359
360
|
// in 1 second -> in 0 seconds.
|
|
360
361
|
var _timeAgo$format = timeAgo.format(1000, 'twitter', {
|
|
361
362
|
refresh: function refresh(text) {
|
|
362
363
|
if (refreshedTimes === 0) {
|
|
363
|
-
expect(text).to.equal('0s');
|
|
364
|
+
(0, _chai.expect)(text).to.equal('0s');
|
|
364
365
|
} else {
|
|
365
366
|
throw new Error('Refresh should have been cancelled');
|
|
366
367
|
}
|
|
@@ -372,171 +373,171 @@ describe("javascript-time-ago", function () {
|
|
|
372
373
|
_timeAgo$format2 = _slicedToArray(_timeAgo$format, 2),
|
|
373
374
|
text = _timeAgo$format2[0],
|
|
374
375
|
cancelRefresh = _timeAgo$format2[1];
|
|
375
|
-
expect(text).to.equal('1s');
|
|
376
|
-
expect(cancelRefresh).to.be.a('function');
|
|
376
|
+
(0, _chai.expect)(text).to.equal('1s');
|
|
377
|
+
(0, _chai.expect)(cancelRefresh).to.be.a('function');
|
|
377
378
|
// Sidenote: `timeToNextUpdate` is `1`.
|
|
378
379
|
var timeToNextUpdate = 1;
|
|
379
380
|
return delay(timeToNextUpdate + 1).then(function () {
|
|
380
|
-
expect(refreshedTimes).to.equal(1);
|
|
381
|
+
(0, _chai.expect)(refreshedTimes).to.equal(1);
|
|
381
382
|
cancelRefresh();
|
|
382
383
|
});
|
|
383
384
|
});
|
|
384
|
-
it('should get time to next update (capped)', function () {
|
|
385
|
+
(0, _mocha.it)('should get time to next update (capped)', function () {
|
|
385
386
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
386
387
|
// in 1 second -> in 0 seconds.
|
|
387
|
-
timeAgo.format(0.5 * 365 * 24 * 60 * 60 * 1000, 'twitter', {
|
|
388
|
+
(0, _chai.expect)(timeAgo.format(0.5 * 365 * 24 * 60 * 60 * 1000, 'twitter', {
|
|
388
389
|
getTimeToNextUpdate: true,
|
|
389
390
|
now: 0,
|
|
390
391
|
round: 'floor'
|
|
391
|
-
}).
|
|
392
|
+
})).to.deep.equal(['Jul 2', 2147483647]);
|
|
392
393
|
});
|
|
393
|
-
it('should get time to next update (capped)', function () {
|
|
394
|
+
(0, _mocha.it)('should get time to next update (capped)', function () {
|
|
394
395
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
395
396
|
// in 1 second -> in 0 seconds.
|
|
396
|
-
timeAgo.format(0.5 * 365 * 24 * 60 * 60 * 1000, 'twitter', {
|
|
397
|
+
(0, _chai.expect)(timeAgo.format(0.5 * 365 * 24 * 60 * 60 * 1000, 'twitter', {
|
|
397
398
|
getTimeToNextUpdate: true,
|
|
398
399
|
getTimeToNextUpdateUncapped: true,
|
|
399
400
|
now: 0,
|
|
400
401
|
round: 'floor'
|
|
401
|
-
}).
|
|
402
|
+
})).to.deep.equal(['Jul 2', 15681600001]);
|
|
402
403
|
});
|
|
403
|
-
it('should get time to next update (uncapped)', function () {
|
|
404
|
+
(0, _mocha.it)('should get time to next update (uncapped)', function () {
|
|
404
405
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
405
406
|
// in 1 second -> in 0 seconds.
|
|
406
|
-
timeAgo.format(1000, 'twitter', {
|
|
407
|
+
(0, _chai.expect)(timeAgo.format(1000, 'twitter', {
|
|
407
408
|
getTimeToNextUpdate: true,
|
|
408
409
|
now: 0,
|
|
409
410
|
round: 'floor'
|
|
410
|
-
}).
|
|
411
|
+
})).to.deep.equal(['1s', 1]);
|
|
411
412
|
});
|
|
412
|
-
it('should get time to next update (round: "floor")', function () {
|
|
413
|
+
(0, _mocha.it)('should get time to next update (round: "floor")', function () {
|
|
413
414
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
414
415
|
// in 1 second -> in 0 seconds.
|
|
415
|
-
timeAgo.format(1000, 'twitter', {
|
|
416
|
+
(0, _chai.expect)(timeAgo.format(1000, 'twitter', {
|
|
416
417
|
getTimeToNextUpdate: true,
|
|
417
418
|
now: 0,
|
|
418
419
|
round: 'floor'
|
|
419
|
-
}).
|
|
420
|
+
})).to.deep.equal(['1s', 1]);
|
|
420
421
|
});
|
|
421
|
-
it('should get time to next update (round: "round")', function () {
|
|
422
|
+
(0, _mocha.it)('should get time to next update (round: "round")', function () {
|
|
422
423
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
423
424
|
// in 1 second -> in 0 seconds.
|
|
424
|
-
timeAgo.format(1000, 'twitter', {
|
|
425
|
+
(0, _chai.expect)(timeAgo.format(1000, 'twitter', {
|
|
425
426
|
getTimeToNextUpdate: true,
|
|
426
427
|
now: 0
|
|
427
|
-
}).
|
|
428
|
+
})).to.deep.equal(['1s', 501]);
|
|
428
429
|
});
|
|
429
|
-
it('should get time to next update ("mini-now" style) (round: "floor")', function () {
|
|
430
|
+
(0, _mocha.it)('should get time to next update ("mini-now" style) (round: "floor")', function () {
|
|
430
431
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
431
432
|
// In 1 minute.
|
|
432
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
433
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
433
434
|
getTimeToNextUpdate: true,
|
|
434
435
|
now: 0,
|
|
435
436
|
round: 'floor'
|
|
436
|
-
}).
|
|
437
|
+
})).to.deep.equal(['1m', 1]);
|
|
437
438
|
// Almost in 1 minute.
|
|
438
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
439
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
439
440
|
getTimeToNextUpdate: true,
|
|
440
441
|
now: 1,
|
|
441
442
|
round: 'floor'
|
|
442
|
-
}).
|
|
443
|
+
})).to.deep.equal(['59s', 1000]);
|
|
443
444
|
// In 1 second.
|
|
444
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
445
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
445
446
|
getTimeToNextUpdate: true,
|
|
446
447
|
now: 59 * 1000,
|
|
447
448
|
round: 'floor'
|
|
448
|
-
}).
|
|
449
|
+
})).to.deep.equal(['1s', 1]);
|
|
449
450
|
// Almost in 1 second.
|
|
450
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
451
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
451
452
|
getTimeToNextUpdate: true,
|
|
452
453
|
now: 59 * 1000 + 1,
|
|
453
454
|
round: 'floor'
|
|
454
|
-
}).
|
|
455
|
+
})).to.deep.equal(['now',
|
|
455
456
|
// Right after zero point.
|
|
456
457
|
1000]);
|
|
457
458
|
// Zero point (future to past).
|
|
458
459
|
// `future: true`.
|
|
459
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
460
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
460
461
|
getTimeToNextUpdate: true,
|
|
461
462
|
now: 60 * 1000,
|
|
462
463
|
future: true,
|
|
463
464
|
round: 'floor'
|
|
464
|
-
}).
|
|
465
|
+
})).to.deep.equal(['now', 1]);
|
|
465
466
|
// Zero point (future to past).
|
|
466
467
|
// `future: false`.
|
|
467
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
468
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
468
469
|
getTimeToNextUpdate: true,
|
|
469
470
|
now: 60 * 1000,
|
|
470
471
|
round: 'floor'
|
|
471
|
-
}).
|
|
472
|
+
})).to.deep.equal(['now', 1000]);
|
|
472
473
|
// Right after zero point (past).
|
|
473
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
474
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
474
475
|
getTimeToNextUpdate: true,
|
|
475
476
|
now: 60 * 1000 + 1,
|
|
476
477
|
round: 'floor'
|
|
477
|
-
}).
|
|
478
|
+
})).to.deep.equal(['now', 1000 - 1]);
|
|
478
479
|
// 1 second ago.
|
|
479
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
480
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
480
481
|
getTimeToNextUpdate: true,
|
|
481
482
|
now: 60 * 1000 + 1000,
|
|
482
483
|
round: 'floor'
|
|
483
|
-
}).
|
|
484
|
+
})).to.deep.equal(['1s', 1000]);
|
|
484
485
|
});
|
|
485
|
-
it('should get time to next update ("mini-now" style) (round: "round")', function () {
|
|
486
|
+
(0, _mocha.it)('should get time to next update ("mini-now" style) (round: "round")', function () {
|
|
486
487
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
487
488
|
// In 1 minute.
|
|
488
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
489
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
489
490
|
getTimeToNextUpdate: true,
|
|
490
491
|
now: 0
|
|
491
|
-
}).
|
|
492
|
+
})).to.deep.equal(['1m', 500 + 1]);
|
|
492
493
|
// Almost in 1 minute.
|
|
493
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
494
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
494
495
|
getTimeToNextUpdate: true,
|
|
495
496
|
now: 500 + 1
|
|
496
|
-
}).
|
|
497
|
+
})).to.deep.equal(['59s', 1000]);
|
|
497
498
|
// In 1 second.
|
|
498
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
499
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
499
500
|
getTimeToNextUpdate: true,
|
|
500
501
|
now: 59.5 * 1000
|
|
501
|
-
}).
|
|
502
|
+
})).to.deep.equal(['1s', 1]);
|
|
502
503
|
// Almost in 1 second.
|
|
503
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
504
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
504
505
|
getTimeToNextUpdate: true,
|
|
505
506
|
now: 59.5 * 1000 + 1
|
|
506
|
-
}).
|
|
507
|
+
})).to.deep.equal(['now',
|
|
507
508
|
// Right after zero point.
|
|
508
509
|
500]);
|
|
509
510
|
// Zero point (future to past).
|
|
510
511
|
// `future: true`.
|
|
511
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
512
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
512
513
|
getTimeToNextUpdate: true,
|
|
513
514
|
now: 60 * 1000,
|
|
514
515
|
future: true
|
|
515
|
-
}).
|
|
516
|
+
})).to.deep.equal(['now', 1]);
|
|
516
517
|
// Zero point (future to past).
|
|
517
518
|
// `future: false`.
|
|
518
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
519
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
519
520
|
getTimeToNextUpdate: true,
|
|
520
521
|
now: 60 * 1000
|
|
521
|
-
}).
|
|
522
|
+
})).to.deep.equal(['now', 500]);
|
|
522
523
|
// Right after zero point (past).
|
|
523
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
524
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
524
525
|
getTimeToNextUpdate: true,
|
|
525
526
|
now: 60 * 1000 + 1
|
|
526
|
-
}).
|
|
527
|
+
})).to.deep.equal(['now', 500 - 1]);
|
|
527
528
|
// 1 second ago.
|
|
528
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
529
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
529
530
|
getTimeToNextUpdate: true,
|
|
530
531
|
now: 60 * 1000 + 500
|
|
531
|
-
}).
|
|
532
|
+
})).to.deep.equal(['1s', 1000]);
|
|
532
533
|
});
|
|
533
|
-
it('should get time to next update (first step has non-zero "minTime") (round: "floor")', function () {
|
|
534
|
+
(0, _mocha.it)('should get time to next update (first step has non-zero "minTime") (round: "floor")', function () {
|
|
534
535
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
535
536
|
|
|
536
537
|
// Future.
|
|
537
538
|
// Inside the first step.
|
|
538
539
|
// Updates soon.
|
|
539
|
-
timeAgo.format(60 * 1000, {
|
|
540
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, {
|
|
540
541
|
steps: [{
|
|
541
542
|
formatAs: 'minute',
|
|
542
543
|
minTime: 60
|
|
@@ -546,12 +547,12 @@ describe("javascript-time-ago", function () {
|
|
|
546
547
|
}, {
|
|
547
548
|
getTimeToNextUpdate: true,
|
|
548
549
|
now: -0.5 * 1000
|
|
549
|
-
}).
|
|
550
|
+
})).to.deep.equal(['1m', 0.5 * 1000 + 1]);
|
|
550
551
|
|
|
551
552
|
// Future.
|
|
552
553
|
// Outside of the first step.
|
|
553
554
|
// Updates right after zero point.
|
|
554
|
-
timeAgo.format(60 * 1000, {
|
|
555
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, {
|
|
555
556
|
steps: [{
|
|
556
557
|
formatAs: 'minute',
|
|
557
558
|
minTime: 60 * 1000
|
|
@@ -561,12 +562,12 @@ describe("javascript-time-ago", function () {
|
|
|
561
562
|
}, {
|
|
562
563
|
getTimeToNextUpdate: true,
|
|
563
564
|
now: 1 * 1000
|
|
564
|
-
}).
|
|
565
|
+
})).to.deep.equal(['', 59 * 1000 + 1]);
|
|
565
566
|
|
|
566
567
|
// Zero point.
|
|
567
568
|
// Outside of the first step.
|
|
568
569
|
// Updates at the first step's `minTime`.
|
|
569
|
-
timeAgo.format(60 * 1000, {
|
|
570
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, {
|
|
570
571
|
steps: [{
|
|
571
572
|
formatAs: 'minute',
|
|
572
573
|
minTime: 60
|
|
@@ -576,12 +577,12 @@ describe("javascript-time-ago", function () {
|
|
|
576
577
|
}, {
|
|
577
578
|
getTimeToNextUpdate: true,
|
|
578
579
|
now: 60 * 1000
|
|
579
|
-
}).
|
|
580
|
+
})).to.deep.equal(['', 60 * 1000]);
|
|
580
581
|
|
|
581
582
|
// Past.
|
|
582
583
|
// Inside the first step.
|
|
583
584
|
// Updates at the next minute.
|
|
584
|
-
timeAgo.format(60 * 1000, {
|
|
585
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, {
|
|
585
586
|
steps: [{
|
|
586
587
|
formatAs: 'minute',
|
|
587
588
|
minTime: 60
|
|
@@ -591,60 +592,60 @@ describe("javascript-time-ago", function () {
|
|
|
591
592
|
}, {
|
|
592
593
|
getTimeToNextUpdate: true,
|
|
593
594
|
now: 60 * 1000 + 60 * 1000
|
|
594
|
-
}).
|
|
595
|
+
})).to.deep.equal(['1m', 60 * 1000]);
|
|
595
596
|
|
|
596
597
|
// Almost in 1 minute.
|
|
597
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
598
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
598
599
|
getTimeToNextUpdate: true,
|
|
599
600
|
now: 1,
|
|
600
601
|
round: 'floor'
|
|
601
|
-
}).
|
|
602
|
+
})).to.deep.equal(['59s', 1000]);
|
|
602
603
|
// In 1 second.
|
|
603
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
604
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
604
605
|
getTimeToNextUpdate: true,
|
|
605
606
|
now: 59 * 1000,
|
|
606
607
|
round: 'floor'
|
|
607
|
-
}).
|
|
608
|
+
})).to.deep.equal(['1s', 1]);
|
|
608
609
|
// Almost in 1 second.
|
|
609
610
|
// Updates right after the zero point.
|
|
610
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
611
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
611
612
|
getTimeToNextUpdate: true,
|
|
612
613
|
now: 59 * 1000 + 1,
|
|
613
614
|
round: 'floor'
|
|
614
|
-
}).
|
|
615
|
+
})).to.deep.equal(['now', 1000]);
|
|
615
616
|
// Zero point (future to past).
|
|
616
617
|
// `future: true`.
|
|
617
618
|
// Updates right after zero point.
|
|
618
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
619
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
619
620
|
getTimeToNextUpdate: true,
|
|
620
621
|
now: 60 * 1000,
|
|
621
622
|
future: true,
|
|
622
623
|
round: 'floor'
|
|
623
|
-
}).
|
|
624
|
+
})).to.deep.equal(['now', 1]);
|
|
624
625
|
// Zero point (future to past).
|
|
625
626
|
// `future: false`.
|
|
626
627
|
// Updates at the next second.
|
|
627
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
628
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
628
629
|
getTimeToNextUpdate: true,
|
|
629
630
|
now: 60 * 1000,
|
|
630
631
|
round: 'floor'
|
|
631
|
-
}).
|
|
632
|
+
})).to.deep.equal(['now', 1000]);
|
|
632
633
|
// Right after zero point (past).
|
|
633
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
634
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
634
635
|
getTimeToNextUpdate: true,
|
|
635
636
|
now: 60 * 1000 + 1,
|
|
636
637
|
round: 'floor'
|
|
637
|
-
}).
|
|
638
|
+
})).to.deep.equal(['now', 1000 - 1]);
|
|
638
639
|
// 1 second ago.
|
|
639
|
-
timeAgo.format(60 * 1000, 'mini-now', {
|
|
640
|
+
(0, _chai.expect)(timeAgo.format(60 * 1000, 'mini-now', {
|
|
640
641
|
getTimeToNextUpdate: true,
|
|
641
642
|
now: 60 * 1000 + 1000,
|
|
642
643
|
round: 'floor'
|
|
643
|
-
}).
|
|
644
|
+
})).to.deep.equal(['1s', 1000]);
|
|
644
645
|
});
|
|
645
|
-
it('should pass `formatAs()` in `step.format()`', function () {
|
|
646
|
+
(0, _mocha.it)('should pass `formatAs()` in `step.format()`', function () {
|
|
646
647
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
647
|
-
timeAgo.format(Date.now(), {
|
|
648
|
+
(0, _chai.expect)(timeAgo.format(Date.now(), {
|
|
648
649
|
labels: 'long',
|
|
649
650
|
steps: [{
|
|
650
651
|
format: function format(date, locale, _ref4) {
|
|
@@ -652,41 +653,41 @@ describe("javascript-time-ago", function () {
|
|
|
652
653
|
return formatAs('second', 1);
|
|
653
654
|
}
|
|
654
655
|
}]
|
|
655
|
-
}).
|
|
656
|
+
})).to.equal('in 1 second');
|
|
656
657
|
});
|
|
657
|
-
it('should support `polyfill: false` option', function () {
|
|
658
|
+
(0, _mocha.it)('should support `polyfill: false` option', function () {
|
|
658
659
|
var timeAgo = new _TimeAgo["default"]('en', {
|
|
659
660
|
polyfill: false
|
|
660
661
|
});
|
|
661
662
|
// Still uses "now" labels, even when not polyfilled.
|
|
662
|
-
timeAgo.format(0, 'round', {
|
|
663
|
+
(0, _chai.expect)(timeAgo.format(0, 'round', {
|
|
663
664
|
now: 0
|
|
664
|
-
}).
|
|
665
|
-
timeAgo.format(1000, 'round', {
|
|
665
|
+
})).to.equal('just now');
|
|
666
|
+
(0, _chai.expect)(timeAgo.format(1000, 'round', {
|
|
666
667
|
now: 0
|
|
667
|
-
}).
|
|
668
|
+
})).to.equal('in 1 second');
|
|
668
669
|
});
|
|
669
|
-
it('should not use Intl.NumberFormat if it is not available', function () {
|
|
670
|
+
(0, _mocha.it)('should not use Intl.NumberFormat if it is not available', function () {
|
|
670
671
|
var Intl = global.Intl;
|
|
671
672
|
global.Intl = undefined;
|
|
672
673
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
673
|
-
timeAgo.format(1000, 'round', {
|
|
674
|
+
(0, _chai.expect)(timeAgo.format(1000, 'round', {
|
|
674
675
|
now: 0
|
|
675
|
-
}).
|
|
676
|
+
})).to.equal('in 1 second');
|
|
676
677
|
global.Intl = Intl;
|
|
677
678
|
});
|
|
678
|
-
it('should format `0` in past mode by default', function () {
|
|
679
|
-
new _TimeAgo["default"]('en').format(0, {
|
|
679
|
+
(0, _mocha.it)('should format `0` in past mode by default', function () {
|
|
680
|
+
(0, _chai.expect)(new _TimeAgo["default"]('en').format(0, {
|
|
680
681
|
labels: 'long',
|
|
681
682
|
steps: [{
|
|
682
683
|
formatAs: 'second'
|
|
683
684
|
}]
|
|
684
685
|
}, {
|
|
685
686
|
now: 0
|
|
686
|
-
}).
|
|
687
|
+
})).to.equal('0 seconds ago');
|
|
687
688
|
});
|
|
688
|
-
it('should format `0` in future mode when `future: true` option was passed', function () {
|
|
689
|
-
new _TimeAgo["default"]('en').format(0, {
|
|
689
|
+
(0, _mocha.it)('should format `0` in future mode when `future: true` option was passed', function () {
|
|
690
|
+
(0, _chai.expect)(new _TimeAgo["default"]('en').format(0, {
|
|
690
691
|
labels: 'long',
|
|
691
692
|
steps: [{
|
|
692
693
|
formatAs: 'second'
|
|
@@ -694,23 +695,23 @@ describe("javascript-time-ago", function () {
|
|
|
694
695
|
}, {
|
|
695
696
|
now: 0,
|
|
696
697
|
future: true
|
|
697
|
-
}).
|
|
698
|
+
})).to.equal('in 0 seconds');
|
|
698
699
|
});
|
|
699
|
-
it('should throw if a step does not define `formatAs` or `format()`', function () {
|
|
700
|
+
(0, _mocha.it)('should throw if a step does not define `formatAs` or `format()`', function () {
|
|
700
701
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
701
|
-
expect(function () {
|
|
702
|
+
(0, _chai.expect)(function () {
|
|
702
703
|
return timeAgo.format(Date.now() + 1000, {
|
|
703
704
|
labels: 'long',
|
|
704
705
|
steps: [{}]
|
|
705
706
|
});
|
|
706
707
|
}).to["throw"]('Each step must define either `formatAs` or `format()`.');
|
|
707
708
|
});
|
|
708
|
-
it('should add default locale', function () {
|
|
709
|
-
_TimeAgo["default"].getDefaultLocale().
|
|
709
|
+
(0, _mocha.it)('should add default locale', function () {
|
|
710
|
+
(0, _chai.expect)(_TimeAgo["default"].getDefaultLocale()).to.equal('en');
|
|
710
711
|
_TimeAgo["default"].addDefaultLocale({
|
|
711
712
|
locale: 'el'
|
|
712
713
|
});
|
|
713
|
-
_TimeAgo["default"].getDefaultLocale().
|
|
714
|
+
(0, _chai.expect)(_TimeAgo["default"].getDefaultLocale()).to.equal('el');
|
|
714
715
|
// Doesn't throw an error because the same locale is already specified as default.
|
|
715
716
|
_TimeAgo["default"].addDefaultLocale({
|
|
716
717
|
locale: 'el'
|
|
@@ -723,32 +724,32 @@ describe("javascript-time-ago", function () {
|
|
|
723
724
|
// }).to.throw('but you have already added "el" as the default locale.')
|
|
724
725
|
_TimeAgo["default"].setDefaultLocale('en');
|
|
725
726
|
});
|
|
726
|
-
it('should support "floor" rounding', function () {
|
|
727
|
+
(0, _mocha.it)('should support "floor" rounding', function () {
|
|
727
728
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
728
|
-
timeAgo.format(0.9 * 1000, 'twitter', {
|
|
729
|
+
(0, _chai.expect)(timeAgo.format(0.9 * 1000, 'twitter', {
|
|
729
730
|
now: 0,
|
|
730
731
|
round: 'floor'
|
|
731
|
-
}).
|
|
732
|
-
timeAgo.format(1 * 1000, 'twitter', {
|
|
732
|
+
})).to.equal('0s');
|
|
733
|
+
(0, _chai.expect)(timeAgo.format(1 * 1000, 'twitter', {
|
|
733
734
|
now: 0,
|
|
734
735
|
round: 'floor'
|
|
735
|
-
}).
|
|
736
|
-
timeAgo.format(1.9 * 1000, 'twitter', {
|
|
736
|
+
})).to.equal('1s');
|
|
737
|
+
(0, _chai.expect)(timeAgo.format(1.9 * 1000, 'twitter', {
|
|
737
738
|
now: 0,
|
|
738
739
|
round: 'floor'
|
|
739
|
-
}).
|
|
740
|
-
timeAgo.format(2 * 1000, 'twitter', {
|
|
740
|
+
})).to.equal('1s');
|
|
741
|
+
(0, _chai.expect)(timeAgo.format(2 * 1000, 'twitter', {
|
|
741
742
|
now: 0,
|
|
742
743
|
round: 'floor'
|
|
743
|
-
}).
|
|
744
|
-
timeAgo.format(1.9 * 60 * 1000, 'twitter', {
|
|
744
|
+
})).to.equal('2s');
|
|
745
|
+
(0, _chai.expect)(timeAgo.format(1.9 * 60 * 1000, 'twitter', {
|
|
745
746
|
now: 0,
|
|
746
747
|
round: 'floor'
|
|
747
|
-
}).
|
|
748
|
-
timeAgo.format(2 * 60 * 1000, 'twitter', {
|
|
748
|
+
})).to.equal('1m');
|
|
749
|
+
(0, _chai.expect)(timeAgo.format(2 * 60 * 1000, 'twitter', {
|
|
749
750
|
now: 0,
|
|
750
751
|
round: 'floor'
|
|
751
|
-
}).
|
|
752
|
+
})).to.equal('2m');
|
|
752
753
|
});
|
|
753
754
|
});
|
|
754
755
|
function delay(delayTime) {
|