@sproutsocial/seeds-react-duration 1.0.31 → 1.0.32

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.
@@ -1,102 +0,0 @@
1
- import testDuration from "./testDuration";
2
-
3
- const options = { display: "long" };
4
-
5
- describe("When setting display long...", () => {
6
- describe("... it renders properly", () => {
7
- testDuration(1, options, { text: "0 seconds" });
8
- testDuration(2, options, { text: "0 seconds" });
9
- testDuration(1000, options, { text: "1 second" });
10
- testDuration(2000, options, { text: "2 seconds" });
11
- testDuration(1001, options, { text: "1 second" });
12
- testDuration(2002, options, { text: "2 seconds" });
13
- testDuration(60000, options, { text: "1 minute" });
14
- testDuration(120000, options, { text: "2 minutes" });
15
- testDuration(61000, options, { text: "1 minute 1 second" });
16
- testDuration(122000, options, { text: "2 minutes 2 seconds" });
17
- testDuration(60001, options, { text: "1 minute" });
18
- testDuration(120002, options, { text: "2 minutes" });
19
- testDuration(61001, options, { text: "1 minute 1 second" });
20
- testDuration(122002, options, {
21
- text: "2 minutes 2 seconds",
22
- });
23
- testDuration(3600000, options, { text: "1 hour" });
24
- testDuration(7200000, options, { text: "2 hours" });
25
- testDuration(3660000, options, { text: "1 hour 1 minute" });
26
- testDuration(7320000, options, { text: "2 hours 2 minutes" });
27
- testDuration(3601000, options, { text: "1 hour 1 second" });
28
- testDuration(7202000, options, { text: "2 hours 2 seconds" });
29
- testDuration(3600001, options, { text: "1 hour" });
30
- testDuration(7200002, options, { text: "2 hours" });
31
- testDuration(3661000, options, { text: "1 hour 1 minute 1 second" });
32
- testDuration(7322000, options, { text: "2 hours 2 minutes 2 seconds" });
33
- testDuration(3601001, options, { text: "1 hour 1 second" });
34
- testDuration(7202002, options, {
35
- text: "2 hours 2 seconds",
36
- });
37
- testDuration(3660001, options, { text: "1 hour 1 minute" });
38
- testDuration(7320002, options, {
39
- text: "2 hours 2 minutes",
40
- });
41
- testDuration(3661001, options, {
42
- text: "1 hour 1 minute 1 second",
43
- });
44
- testDuration(7322002, options, {
45
- text: "2 hours 2 minutes 2 seconds",
46
- });
47
- testDuration(86400000, options, { text: "1 day" });
48
- testDuration(172800000, options, { text: "2 days" });
49
- testDuration(90000000, options, { text: "1 day 1 hour" });
50
- testDuration(180000000, options, { text: "2 days 2 hours" });
51
- testDuration(86460000, options, { text: "1 day 1 minute" });
52
- testDuration(172920000, options, { text: "2 days 2 minutes" });
53
- testDuration(86401000, options, { text: "1 day 1 second" });
54
- testDuration(172802000, options, { text: "2 days 2 seconds" });
55
- testDuration(86400001, options, { text: "1 day" });
56
- testDuration(172800002, options, { text: "2 days" });
57
- testDuration(90060000, options, { text: "1 day 1 hour 1 minute" });
58
- testDuration(180120000, options, { text: "2 days 2 hours 2 minutes" });
59
- testDuration(90001000, options, { text: "1 day 1 hour 1 second" });
60
- testDuration(180002000, options, { text: "2 days 2 hours 2 seconds" });
61
- testDuration(90000001, options, { text: "1 day 1 hour" });
62
- testDuration(180000002, options, { text: "2 days 2 hours" });
63
- testDuration(86461000, options, { text: "1 day 1 minute 1 second" });
64
- testDuration(172922000, options, { text: "2 days 2 minutes 2 seconds" });
65
- testDuration(86460001, options, { text: "1 day 1 minute" });
66
- testDuration(172920002, options, {
67
- text: "2 days 2 minutes",
68
- });
69
- testDuration(86401001, options, { text: "1 day 1 second" });
70
- testDuration(172802002, options, {
71
- text: "2 days 2 seconds",
72
- });
73
- testDuration(90061000, options, { text: "1 day 1 hour 1 minute 1 second" });
74
- testDuration(180122000, options, {
75
- text: "2 days 2 hours 2 minutes 2 seconds",
76
- });
77
- testDuration(86461001, options, {
78
- text: "1 day 1 minute 1 second",
79
- });
80
- testDuration(172922002, options, {
81
- text: "2 days 2 minutes 2 seconds",
82
- });
83
- testDuration(90001001, options, {
84
- text: "1 day 1 hour 1 second",
85
- });
86
- testDuration(180002002, options, {
87
- text: "2 days 2 hours 2 seconds",
88
- });
89
- testDuration(90060001, options, {
90
- text: "1 day 1 hour 1 minute",
91
- });
92
- testDuration(180120002, options, {
93
- text: "2 days 2 hours 2 minutes",
94
- });
95
- testDuration(90061001, options, {
96
- text: "1 day 1 hour 1 minute 1 second",
97
- });
98
- testDuration(180122002, options, {
99
- text: "2 days 2 hours 2 minutes 2 seconds",
100
- });
101
- });
102
- });
@@ -1,548 +0,0 @@
1
- import testDuration from "./testDuration";
2
-
3
- // this value should NOT round up the last digit when applicable (1m 29s = 1)
4
- const duration = 127769499; // 1d 11h 29m 29s 499ms
5
-
6
- // this value SHOULD round up the last digit when applicable (1m 30s = 2m)
7
- const roundingDuration = 131430500; // 1d 12h 30m 30s 500ms
8
-
9
- describe("When using display units...", () => {
10
- describe("... it renders properly", () => {
11
- testDuration(
12
- duration,
13
- {
14
- displayUnits: {
15
- days: true,
16
- hours: true,
17
- minutes: true,
18
- seconds: true,
19
- milliseconds: true,
20
- },
21
- },
22
- { text: "1d 11h 29m 29s 499ms" }
23
- );
24
- testDuration(
25
- duration,
26
- {
27
- displayUnits: {
28
- hours: true,
29
- minutes: true,
30
- seconds: true,
31
- milliseconds: true,
32
- },
33
- },
34
- { text: "35h 29m 29s 499ms" }
35
- );
36
- testDuration(
37
- duration,
38
- {
39
- displayUnits: {
40
- days: true,
41
- minutes: true,
42
- seconds: true,
43
- milliseconds: true,
44
- },
45
- },
46
- { text: "1d 689m 29s 499ms" }
47
- );
48
- testDuration(
49
- duration,
50
- {
51
- displayUnits: {
52
- days: true,
53
- hours: true,
54
- seconds: true,
55
- milliseconds: true,
56
- },
57
- },
58
- { text: "1d 11h 1,769s 499ms" }
59
- );
60
- testDuration(
61
- duration,
62
- {
63
- displayUnits: {
64
- days: true,
65
- hours: true,
66
- minutes: true,
67
- milliseconds: true,
68
- },
69
- },
70
- { text: "1d 11h 29m 29,499ms" }
71
- );
72
- testDuration(
73
- duration,
74
- {
75
- displayUnits: {
76
- days: true,
77
- hours: true,
78
- minutes: true,
79
- seconds: true,
80
- },
81
- },
82
- { text: "1d 11h 29m 29s" }
83
- );
84
- testDuration(
85
- duration,
86
- {
87
- displayUnits: { minutes: true, seconds: true, milliseconds: true },
88
- },
89
- { text: "2,129m 29s 499ms" }
90
- );
91
- testDuration(
92
- duration,
93
- {
94
- displayUnits: { hours: true, seconds: true, milliseconds: true },
95
- },
96
- { text: "35h 1,769s 499ms" }
97
- );
98
- testDuration(
99
- duration,
100
- {
101
- displayUnits: { hours: true, minutes: true, milliseconds: true },
102
- },
103
- { text: "35h 29m 29,499ms" }
104
- );
105
- testDuration(
106
- duration,
107
- {
108
- displayUnits: { hours: true, minutes: true, seconds: true },
109
- },
110
- { text: "35h 29m 29s" }
111
- );
112
- testDuration(
113
- duration,
114
- {
115
- displayUnits: { days: true, seconds: true, milliseconds: true },
116
- },
117
- { text: "1d 41,369s 499ms" }
118
- );
119
- testDuration(
120
- duration,
121
- {
122
- displayUnits: { days: true, minutes: true, milliseconds: true },
123
- },
124
- { text: "1d 689m 29,499ms" }
125
- );
126
- testDuration(
127
- duration,
128
- {
129
- displayUnits: { days: true, minutes: true, seconds: true },
130
- },
131
- { text: "1d 689m 29s" }
132
- );
133
- testDuration(
134
- duration,
135
- {
136
- displayUnits: { days: true, hours: true, milliseconds: true },
137
- },
138
- { text: "1d 11h 1,769,499ms" }
139
- );
140
- testDuration(
141
- duration,
142
- {
143
- displayUnits: { days: true, hours: true, seconds: true },
144
- },
145
- { text: "1d 11h 1,769s" }
146
- );
147
- testDuration(
148
- duration,
149
- {
150
- displayUnits: { days: true, hours: true, minutes: true },
151
- },
152
- { text: "1d 11h 29m" }
153
- );
154
- testDuration(
155
- duration,
156
- {
157
- displayUnits: {
158
- seconds: true,
159
- milliseconds: true,
160
- },
161
- },
162
- { text: "127,769s 499ms" }
163
- );
164
- testDuration(
165
- duration,
166
- {
167
- displayUnits: {
168
- minutes: true,
169
- milliseconds: true,
170
- },
171
- },
172
- { text: "2,129m 29,499ms" }
173
- );
174
- testDuration(
175
- duration,
176
- {
177
- displayUnits: {
178
- minutes: true,
179
- seconds: true,
180
- },
181
- },
182
- { text: "2,129m 29s" }
183
- );
184
- testDuration(
185
- duration,
186
- {
187
- displayUnits: {
188
- hours: true,
189
- milliseconds: true,
190
- },
191
- },
192
- { text: "35h 1,769,499ms" }
193
- );
194
- testDuration(
195
- duration,
196
- {
197
- displayUnits: {
198
- hours: true,
199
- seconds: true,
200
- },
201
- },
202
- { text: "35h 1,769s" }
203
- );
204
- testDuration(
205
- duration,
206
- {
207
- displayUnits: {
208
- hours: true,
209
- minutes: true,
210
- },
211
- },
212
- { text: "35h 29m" }
213
- );
214
- testDuration(
215
- duration,
216
- {
217
- displayUnits: {
218
- days: true,
219
- milliseconds: true,
220
- },
221
- },
222
- { text: "1d 41,369,499ms" }
223
- );
224
- testDuration(
225
- duration,
226
- {
227
- displayUnits: {
228
- days: true,
229
- seconds: true,
230
- },
231
- },
232
- { text: "1d 41,369s" }
233
- );
234
- testDuration(
235
- duration,
236
- {
237
- displayUnits: {
238
- days: true,
239
- minutes: true,
240
- },
241
- },
242
- { text: "1d 689m" }
243
- );
244
- testDuration(
245
- duration,
246
- {
247
- displayUnits: {
248
- days: true,
249
- hours: true,
250
- },
251
- },
252
- { text: "1d 11h" }
253
- );
254
- testDuration(duration, { displayUnits: { days: true } }, { text: "1d" });
255
- testDuration(duration, { displayUnits: { hours: true } }, { text: "35h" });
256
- testDuration(
257
- duration,
258
- { displayUnits: { minutes: true } },
259
- { text: "2,129m" }
260
- );
261
- testDuration(
262
- duration,
263
- { displayUnits: { seconds: true } },
264
- { text: "127,769s" }
265
- );
266
- testDuration(
267
- duration,
268
- { displayUnits: { milliseconds: true } },
269
- { text: "127,769,499ms" }
270
- );
271
- testDuration(duration, { displayUnits: {} }, { text: "1d 11h 29m 29s" });
272
- });
273
- describe("... it renders properly while rounding up the last digit", () => {
274
- testDuration(
275
- roundingDuration,
276
- {
277
- displayUnits: {
278
- days: true,
279
- hours: true,
280
- minutes: true,
281
- seconds: true,
282
- milliseconds: true,
283
- },
284
- },
285
- { text: "1d 12h 30m 30s 500ms" }
286
- );
287
- testDuration(
288
- roundingDuration,
289
- {
290
- displayUnits: {
291
- hours: true,
292
- minutes: true,
293
- seconds: true,
294
- milliseconds: true,
295
- },
296
- },
297
- { text: "36h 30m 30s 500ms" }
298
- );
299
- testDuration(
300
- roundingDuration,
301
- {
302
- displayUnits: {
303
- days: true,
304
- minutes: true,
305
- seconds: true,
306
- milliseconds: true,
307
- },
308
- },
309
- { text: "1d 750m 30s 500ms" }
310
- );
311
- testDuration(
312
- roundingDuration,
313
- {
314
- displayUnits: {
315
- days: true,
316
- hours: true,
317
- seconds: true,
318
- milliseconds: true,
319
- },
320
- },
321
- { text: "1d 12h 1,830s 500ms" }
322
- );
323
- testDuration(
324
- roundingDuration,
325
- {
326
- displayUnits: {
327
- days: true,
328
- hours: true,
329
- minutes: true,
330
- milliseconds: true,
331
- },
332
- },
333
- { text: "1d 12h 30m 30,500ms" }
334
- );
335
- testDuration(
336
- roundingDuration,
337
- {
338
- displayUnits: {
339
- days: true,
340
- hours: true,
341
- minutes: true,
342
- seconds: true,
343
- },
344
- },
345
- { text: "1d 12h 30m 31s" }
346
- );
347
- testDuration(
348
- roundingDuration,
349
- {
350
- displayUnits: { minutes: true, seconds: true, milliseconds: true },
351
- },
352
- { text: "2,190m 30s 500ms" }
353
- );
354
- testDuration(
355
- roundingDuration,
356
- {
357
- displayUnits: { hours: true, seconds: true, milliseconds: true },
358
- },
359
- { text: "36h 1,830s 500ms" }
360
- );
361
- testDuration(
362
- roundingDuration,
363
- {
364
- displayUnits: { hours: true, minutes: true, milliseconds: true },
365
- },
366
- { text: "36h 30m 30,500ms" }
367
- );
368
- testDuration(
369
- roundingDuration,
370
- {
371
- displayUnits: { hours: true, minutes: true, seconds: true },
372
- },
373
- { text: "36h 30m 31s" }
374
- );
375
- testDuration(
376
- roundingDuration,
377
- {
378
- displayUnits: { days: true, seconds: true, milliseconds: true },
379
- },
380
- { text: "1d 45,030s 500ms" }
381
- );
382
- testDuration(
383
- roundingDuration,
384
- {
385
- displayUnits: { days: true, minutes: true, milliseconds: true },
386
- },
387
- { text: "1d 750m 30,500ms" }
388
- );
389
- testDuration(
390
- roundingDuration,
391
- {
392
- displayUnits: { days: true, minutes: true, seconds: true },
393
- },
394
- { text: "1d 750m 31s" }
395
- );
396
- testDuration(
397
- roundingDuration,
398
- {
399
- displayUnits: { days: true, hours: true, milliseconds: true },
400
- },
401
- { text: "1d 12h 1,830,500ms" }
402
- );
403
- testDuration(
404
- roundingDuration,
405
- {
406
- displayUnits: { days: true, hours: true, seconds: true },
407
- },
408
- { text: "1d 12h 1,831s" }
409
- );
410
- testDuration(
411
- roundingDuration,
412
- {
413
- displayUnits: { days: true, hours: true, minutes: true },
414
- },
415
- { text: "1d 12h 31m" }
416
- );
417
- testDuration(
418
- roundingDuration,
419
- {
420
- displayUnits: {
421
- seconds: true,
422
- milliseconds: true,
423
- },
424
- },
425
- { text: "131,430s 500ms" }
426
- );
427
- testDuration(
428
- roundingDuration,
429
- {
430
- displayUnits: {
431
- minutes: true,
432
- milliseconds: true,
433
- },
434
- },
435
- { text: "2,190m 30,500ms" }
436
- );
437
- testDuration(
438
- roundingDuration,
439
- {
440
- displayUnits: {
441
- minutes: true,
442
- seconds: true,
443
- },
444
- },
445
- { text: "2,190m 31s" }
446
- );
447
- testDuration(
448
- roundingDuration,
449
- {
450
- displayUnits: {
451
- hours: true,
452
- milliseconds: true,
453
- },
454
- },
455
- { text: "36h 1,830,500ms" }
456
- );
457
- testDuration(
458
- roundingDuration,
459
- {
460
- displayUnits: {
461
- hours: true,
462
- seconds: true,
463
- },
464
- },
465
- { text: "36h 1,831s" }
466
- );
467
- testDuration(
468
- roundingDuration,
469
- {
470
- displayUnits: {
471
- hours: true,
472
- minutes: true,
473
- },
474
- },
475
- { text: "36h 31m" }
476
- );
477
- testDuration(
478
- roundingDuration,
479
- {
480
- displayUnits: {
481
- days: true,
482
- milliseconds: true,
483
- },
484
- },
485
- { text: "1d 45,030,500ms" }
486
- );
487
- testDuration(
488
- roundingDuration,
489
- {
490
- displayUnits: {
491
- days: true,
492
- seconds: true,
493
- },
494
- },
495
- { text: "1d 45,031s" }
496
- );
497
- testDuration(
498
- roundingDuration,
499
- {
500
- displayUnits: {
501
- days: true,
502
- minutes: true,
503
- },
504
- },
505
- { text: "1d 751m" }
506
- );
507
- testDuration(
508
- roundingDuration,
509
- {
510
- displayUnits: {
511
- days: true,
512
- hours: true,
513
- },
514
- },
515
- { text: "1d 13h" }
516
- );
517
- testDuration(
518
- roundingDuration,
519
- { displayUnits: { days: true } },
520
- { text: "2d" }
521
- );
522
- testDuration(
523
- roundingDuration,
524
- { displayUnits: { hours: true } },
525
- { text: "37h" }
526
- );
527
- testDuration(
528
- roundingDuration,
529
- { displayUnits: { minutes: true } },
530
- { text: "2,191m" }
531
- );
532
- testDuration(
533
- roundingDuration,
534
- { displayUnits: { seconds: true } },
535
- { text: "131,431s" }
536
- );
537
- testDuration(
538
- roundingDuration,
539
- { displayUnits: { milliseconds: true } },
540
- { text: "131,430,500ms" }
541
- );
542
- testDuration(
543
- roundingDuration,
544
- { displayUnits: {} },
545
- { text: "1d 12h 30m 31s" }
546
- );
547
- });
548
- });
@@ -1,32 +0,0 @@
1
- import { EM_DASH } from "../../constants";
2
- import testDuration from "./testDuration";
3
-
4
- describe("When using an invalid value...", () => {
5
- describe("... it renders a dash", () => {
6
- testDuration(
7
- undefined,
8
- { invalidMillisecondsLabel: "Not available" },
9
- { text: EM_DASH, label: "Not available" }
10
- );
11
- testDuration(
12
- null,
13
- { invalidMillisecondsLabel: "Not available" },
14
- { text: EM_DASH, label: "Not available" }
15
- );
16
- testDuration(
17
- NaN,
18
- { invalidMillisecondsLabel: "Not available" },
19
- { text: EM_DASH, label: "Not available" }
20
- );
21
- testDuration(
22
- Infinity,
23
- { invalidMillisecondsLabel: "Not available" },
24
- { text: EM_DASH, label: "Not available" }
25
- );
26
- testDuration(
27
- -Infinity,
28
- { invalidMillisecondsLabel: "Not available" },
29
- { text: EM_DASH, label: "Not available" }
30
- );
31
- });
32
- });