@zohodesk/i18n 1.0.0-beta.34 → 1.0.0-beta.35-murphy
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/docs/murphy/01-MURPHY_OVERVIEW.md +148 -0
- package/docs/murphy/02-MURPHY_ARCHITECTURE.md +283 -0
- package/docs/murphy/03-MURPHY_BACKEND_CONFIG.md +337 -0
- package/docs/murphy/04-MURPHY_FRONTEND_INIT.md +437 -0
- package/docs/murphy/05-MURPHY_DESK_CLIENT_USAGE.md +467 -0
- package/docs/murphy/06-MURPHY_I18N_INTEGRATION.md +402 -0
- package/docs/murphy/07-MURPHY_WHY_I18N_APPROACH.md +391 -0
- package/es/components/DateTimeDiffFormat.js +5 -19
- package/es/components/FormatText.js +2 -2
- package/es/components/HOCI18N.js +32 -43
- package/es/components/I18N.js +2 -13
- package/es/components/I18NProvider.js +0 -9
- package/es/components/PluralFormat.js +3 -5
- package/es/components/UserTimeDiffFormat.js +5 -9
- package/es/components/__tests__/DateTimeDiffFormat.spec.js +157 -221
- package/es/components/__tests__/FormatText.spec.js +2 -2
- package/es/components/__tests__/HOCI18N.spec.js +2 -4
- package/es/components/__tests__/I18N.spec.js +6 -4
- package/es/components/__tests__/I18NProvider.spec.js +4 -4
- package/es/components/__tests__/PluralFormat.spec.js +2 -2
- package/es/components/__tests__/UserTimeDiffFormat.spec.js +249 -348
- package/es/index.js +1 -0
- package/es/utils/__tests__/jsxTranslations.spec.js +3 -7
- package/es/utils/errorReporter.js +31 -0
- package/es/utils/index.js +42 -92
- package/es/utils/jsxTranslations.js +34 -52
- package/lib/I18NContext.js +2 -7
- package/lib/components/DateTimeDiffFormat.js +46 -87
- package/lib/components/FormatText.js +18 -41
- package/lib/components/HOCI18N.js +24 -59
- package/lib/components/I18N.js +27 -64
- package/lib/components/I18NProvider.js +27 -63
- package/lib/components/PluralFormat.js +24 -50
- package/lib/components/UserTimeDiffFormat.js +43 -72
- package/lib/components/__tests__/DateTimeDiffFormat.spec.js +95 -165
- package/lib/components/__tests__/FormatText.spec.js +3 -10
- package/lib/components/__tests__/HOCI18N.spec.js +3 -14
- package/lib/components/__tests__/I18N.spec.js +4 -12
- package/lib/components/__tests__/I18NProvider.spec.js +8 -23
- package/lib/components/__tests__/PluralFormat.spec.js +3 -11
- package/lib/components/__tests__/UserTimeDiffFormat.spec.js +157 -225
- package/lib/index.js +25 -23
- package/lib/utils/__tests__/jsxTranslations.spec.js +1 -12
- package/lib/utils/errorReporter.js +39 -0
- package/lib/utils/index.js +49 -125
- package/lib/utils/jsxTranslations.js +61 -100
- package/package.json +1 -1
- package/src/index.js +5 -0
- package/src/utils/errorReporter.js +36 -0
- package/src/utils/index.js +8 -1
- package/src/utils/jsxTranslations.js +8 -1
|
@@ -10,10 +10,8 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
10
10
|
if (a) {
|
|
11
11
|
return new temp(a);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
13
|
return new temp('2016-10-25T05:55:28.000Z');
|
|
15
14
|
};
|
|
16
|
-
|
|
17
15
|
Date.UTC = temp.UTC;
|
|
18
16
|
Date.now = temp.now;
|
|
19
17
|
});
|
|
@@ -21,9 +19,8 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
21
19
|
Date = temp;
|
|
22
20
|
});
|
|
23
21
|
/* eslint-enable */
|
|
24
|
-
|
|
25
22
|
it('Should display yesterday - with same time', () => {
|
|
26
|
-
let ele = renderer.create(
|
|
23
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
27
24
|
i18n: {
|
|
28
25
|
today: 'today',
|
|
29
26
|
yesterday: 'yesterday'
|
|
@@ -43,15 +40,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
43
40
|
key: 'tomorrow',
|
|
44
41
|
params: ['hh', 'mm', 'ss']
|
|
45
42
|
},
|
|
46
|
-
others:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
} = _ref;
|
|
53
|
-
return 'DD-MM-YYYY';
|
|
54
|
-
},
|
|
43
|
+
others: ({
|
|
44
|
+
years,
|
|
45
|
+
days,
|
|
46
|
+
hours,
|
|
47
|
+
minutes
|
|
48
|
+
}) => 'DD-MM-YYYY',
|
|
55
49
|
ago: "ago",
|
|
56
50
|
later: "later"
|
|
57
51
|
})));
|
|
@@ -59,7 +53,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
59
53
|
expect(tree).toMatchSnapshot();
|
|
60
54
|
});
|
|
61
55
|
it('Should display yesterday - less than 24 hour', () => {
|
|
62
|
-
let ele = renderer.create(
|
|
56
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
63
57
|
i18n: {
|
|
64
58
|
today: 'today',
|
|
65
59
|
yesterday: 'yesterday'
|
|
@@ -80,15 +74,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
80
74
|
key: 'tomorrow',
|
|
81
75
|
params: ['hh', 'mm', 'ss']
|
|
82
76
|
},
|
|
83
|
-
others:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
} = _ref2;
|
|
90
|
-
return 'DD-MM-YYYY';
|
|
91
|
-
},
|
|
77
|
+
others: ({
|
|
78
|
+
years,
|
|
79
|
+
days,
|
|
80
|
+
hours,
|
|
81
|
+
minutes
|
|
82
|
+
}) => 'DD-MM-YYYY',
|
|
92
83
|
ago: "ago",
|
|
93
84
|
later: "later"
|
|
94
85
|
})));
|
|
@@ -96,7 +87,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
96
87
|
expect(tree).toMatchSnapshot();
|
|
97
88
|
});
|
|
98
89
|
it('Should display yesterday - greater than 24 hour', () => {
|
|
99
|
-
let ele = renderer.create(
|
|
90
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
100
91
|
i18n: {
|
|
101
92
|
today: 'today',
|
|
102
93
|
yesterday: 'yesterday'
|
|
@@ -117,15 +108,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
117
108
|
key: 'tomorrow',
|
|
118
109
|
params: ['hh', 'mm', 'ss']
|
|
119
110
|
},
|
|
120
|
-
others:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
} = _ref3;
|
|
127
|
-
return 'DD-MM-YYYY';
|
|
128
|
-
},
|
|
111
|
+
others: ({
|
|
112
|
+
years,
|
|
113
|
+
days,
|
|
114
|
+
hours,
|
|
115
|
+
minutes
|
|
116
|
+
}) => 'DD-MM-YYYY',
|
|
129
117
|
ago: "ago",
|
|
130
118
|
later: "later"
|
|
131
119
|
})));
|
|
@@ -133,7 +121,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
133
121
|
expect(tree).toMatchSnapshot();
|
|
134
122
|
});
|
|
135
123
|
it('Should display today key - same time', () => {
|
|
136
|
-
let ele = renderer.create(
|
|
124
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
137
125
|
i18n: {
|
|
138
126
|
today: 'today',
|
|
139
127
|
yesterday: 'yesterday'
|
|
@@ -154,15 +142,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
154
142
|
key: 'tomorrow',
|
|
155
143
|
params: ['hh', 'mm', 'ss']
|
|
156
144
|
},
|
|
157
|
-
others:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
} = _ref4;
|
|
164
|
-
return 'DD-MM-YYYY';
|
|
165
|
-
},
|
|
145
|
+
others: ({
|
|
146
|
+
years,
|
|
147
|
+
days,
|
|
148
|
+
hours,
|
|
149
|
+
minutes
|
|
150
|
+
}) => 'DD-MM-YYYY',
|
|
166
151
|
ago: "ago",
|
|
167
152
|
later: "later"
|
|
168
153
|
})));
|
|
@@ -170,7 +155,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
170
155
|
expect(tree).toMatchSnapshot();
|
|
171
156
|
});
|
|
172
157
|
it('Should display today key - less than 24 hour', () => {
|
|
173
|
-
let ele = renderer.create(
|
|
158
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
174
159
|
i18n: {
|
|
175
160
|
today: 'today',
|
|
176
161
|
yesterday: 'yesterday'
|
|
@@ -191,15 +176,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
191
176
|
key: 'tomorrow',
|
|
192
177
|
params: ['hh', 'mm', 'ss']
|
|
193
178
|
},
|
|
194
|
-
others:
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
} = _ref5;
|
|
201
|
-
return 'DD-MM-YYYY';
|
|
202
|
-
},
|
|
179
|
+
others: ({
|
|
180
|
+
years,
|
|
181
|
+
days,
|
|
182
|
+
hours,
|
|
183
|
+
minutes
|
|
184
|
+
}) => 'DD-MM-YYYY',
|
|
203
185
|
ago: "ago",
|
|
204
186
|
later: "later"
|
|
205
187
|
})));
|
|
@@ -207,7 +189,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
207
189
|
expect(tree).toMatchSnapshot();
|
|
208
190
|
});
|
|
209
191
|
it('Should display today key - greater than 24 hour', () => {
|
|
210
|
-
let ele = renderer.create(
|
|
192
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
211
193
|
i18n: {
|
|
212
194
|
today: 'today',
|
|
213
195
|
yesterday: 'yesterday'
|
|
@@ -228,15 +210,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
228
210
|
key: 'tomorrow',
|
|
229
211
|
params: ['hh', 'mm', 'ss']
|
|
230
212
|
},
|
|
231
|
-
others:
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
} = _ref6;
|
|
238
|
-
return 'DD-MM-YYYY';
|
|
239
|
-
},
|
|
213
|
+
others: ({
|
|
214
|
+
years,
|
|
215
|
+
days,
|
|
216
|
+
hours,
|
|
217
|
+
minutes
|
|
218
|
+
}) => 'DD-MM-YYYY',
|
|
240
219
|
ago: "ago",
|
|
241
220
|
later: "later"
|
|
242
221
|
})));
|
|
@@ -244,7 +223,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
244
223
|
expect(tree).toMatchSnapshot();
|
|
245
224
|
});
|
|
246
225
|
it('Should display tomorrow key - same time', () => {
|
|
247
|
-
let ele = renderer.create(
|
|
226
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
248
227
|
i18n: {
|
|
249
228
|
today: 'today',
|
|
250
229
|
yesterday: 'yesterday'
|
|
@@ -265,15 +244,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
265
244
|
key: 'tomorrow',
|
|
266
245
|
params: ['hh', 'mm', 'ss']
|
|
267
246
|
},
|
|
268
|
-
others:
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
} = _ref7;
|
|
275
|
-
return 'DD-MM-YYYY';
|
|
276
|
-
},
|
|
247
|
+
others: ({
|
|
248
|
+
years,
|
|
249
|
+
days,
|
|
250
|
+
hours,
|
|
251
|
+
minutes
|
|
252
|
+
}) => 'DD-MM-YYYY',
|
|
277
253
|
ago: "ago",
|
|
278
254
|
later: "later"
|
|
279
255
|
})));
|
|
@@ -281,7 +257,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
281
257
|
expect(tree).toMatchSnapshot();
|
|
282
258
|
});
|
|
283
259
|
it('Should display tomorrow key - less than 24 hour', () => {
|
|
284
|
-
let ele = renderer.create(
|
|
260
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
285
261
|
i18n: {
|
|
286
262
|
today: 'today',
|
|
287
263
|
yesterday: 'yesterday'
|
|
@@ -302,15 +278,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
302
278
|
key: 'tomorrow',
|
|
303
279
|
params: ['hh', 'mm', 'ss']
|
|
304
280
|
},
|
|
305
|
-
others:
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
} = _ref8;
|
|
312
|
-
return 'DD-MM-YYYY';
|
|
313
|
-
},
|
|
281
|
+
others: ({
|
|
282
|
+
years,
|
|
283
|
+
days,
|
|
284
|
+
hours,
|
|
285
|
+
minutes
|
|
286
|
+
}) => 'DD-MM-YYYY',
|
|
314
287
|
ago: "ago",
|
|
315
288
|
later: "later"
|
|
316
289
|
})));
|
|
@@ -318,7 +291,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
318
291
|
expect(tree).toMatchSnapshot();
|
|
319
292
|
});
|
|
320
293
|
it('Should display tomorrow key - greater than 24 hour', () => {
|
|
321
|
-
let ele = renderer.create(
|
|
294
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
322
295
|
i18n: {
|
|
323
296
|
today: 'today',
|
|
324
297
|
yesterday: 'yesterday'
|
|
@@ -339,15 +312,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
339
312
|
key: 'tomorrow',
|
|
340
313
|
params: ['hh', 'mm', 'ss']
|
|
341
314
|
},
|
|
342
|
-
others:
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
} = _ref9;
|
|
349
|
-
return 'DD-MM-YYYY';
|
|
350
|
-
},
|
|
315
|
+
others: ({
|
|
316
|
+
years,
|
|
317
|
+
days,
|
|
318
|
+
hours,
|
|
319
|
+
minutes
|
|
320
|
+
}) => 'DD-MM-YYYY',
|
|
351
321
|
ago: "ago",
|
|
352
322
|
later: "later"
|
|
353
323
|
})));
|
|
@@ -355,7 +325,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
355
325
|
expect(tree).toMatchSnapshot();
|
|
356
326
|
});
|
|
357
327
|
it('Should display other - same time', () => {
|
|
358
|
-
let ele = renderer.create(
|
|
328
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
359
329
|
i18n: {
|
|
360
330
|
today: 'today',
|
|
361
331
|
yesterday: 'yesterday'
|
|
@@ -376,19 +346,16 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
376
346
|
key: 'tomorrow',
|
|
377
347
|
params: ['hh', 'mm', 'ss']
|
|
378
348
|
},
|
|
379
|
-
others:
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
} = _ref10;
|
|
387
|
-
|
|
349
|
+
others: ({
|
|
350
|
+
years,
|
|
351
|
+
days,
|
|
352
|
+
hours,
|
|
353
|
+
minutes,
|
|
354
|
+
suffix
|
|
355
|
+
}) => {
|
|
388
356
|
if (days > 7) {
|
|
389
357
|
return 'DD-MM-YYYY';
|
|
390
358
|
}
|
|
391
|
-
|
|
392
359
|
return '[less 7] DD-MM-YYYY';
|
|
393
360
|
},
|
|
394
361
|
ago: "ago",
|
|
@@ -398,7 +365,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
398
365
|
expect(tree).toMatchSnapshot();
|
|
399
366
|
});
|
|
400
367
|
it('Should display other - greater time', () => {
|
|
401
|
-
let ele = renderer.create(
|
|
368
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
402
369
|
i18n: {
|
|
403
370
|
today: 'today',
|
|
404
371
|
yesterday: 'yesterday'
|
|
@@ -419,19 +386,16 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
419
386
|
key: 'tomorrow',
|
|
420
387
|
params: ['hh', 'mm', 'ss']
|
|
421
388
|
},
|
|
422
|
-
others:
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
} = _ref11;
|
|
430
|
-
|
|
389
|
+
others: ({
|
|
390
|
+
years,
|
|
391
|
+
days,
|
|
392
|
+
hours,
|
|
393
|
+
minutes,
|
|
394
|
+
suffix
|
|
395
|
+
}) => {
|
|
431
396
|
if (days > 7) {
|
|
432
397
|
return 'DD-MM-YYYY';
|
|
433
398
|
}
|
|
434
|
-
|
|
435
399
|
return '[less 7] DD-MM-YYYY';
|
|
436
400
|
},
|
|
437
401
|
ago: "ago",
|
|
@@ -441,7 +405,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
441
405
|
expect(tree).toMatchSnapshot();
|
|
442
406
|
});
|
|
443
407
|
it('Should display other - less time', () => {
|
|
444
|
-
let ele = renderer.create(
|
|
408
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
445
409
|
i18n: {
|
|
446
410
|
today: 'today',
|
|
447
411
|
yesterday: 'yesterday'
|
|
@@ -462,19 +426,16 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
462
426
|
key: 'tomorrow',
|
|
463
427
|
params: ['hh', 'mm', 'ss']
|
|
464
428
|
},
|
|
465
|
-
others:
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
} = _ref12;
|
|
473
|
-
|
|
429
|
+
others: ({
|
|
430
|
+
years,
|
|
431
|
+
days,
|
|
432
|
+
hours,
|
|
433
|
+
minutes,
|
|
434
|
+
suffix
|
|
435
|
+
}) => {
|
|
474
436
|
if (days > 7) {
|
|
475
437
|
return 'DD-MM-YYYY';
|
|
476
438
|
}
|
|
477
|
-
|
|
478
439
|
return '[less 7] DD-MM-YYYY';
|
|
479
440
|
},
|
|
480
441
|
ago: "ago",
|
|
@@ -484,7 +445,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
484
445
|
expect(tree).toMatchSnapshot();
|
|
485
446
|
});
|
|
486
447
|
it('Should display other later- same time', () => {
|
|
487
|
-
let ele = renderer.create(
|
|
448
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
488
449
|
i18n: {
|
|
489
450
|
today: 'today',
|
|
490
451
|
yesterday: 'yesterday'
|
|
@@ -505,20 +466,17 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
505
466
|
key: 'tomorrow',
|
|
506
467
|
params: ['hh', 'mm', 'ss']
|
|
507
468
|
},
|
|
508
|
-
others:
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
} = _ref13;
|
|
517
|
-
|
|
469
|
+
others: ({
|
|
470
|
+
years,
|
|
471
|
+
days,
|
|
472
|
+
hours,
|
|
473
|
+
minutes,
|
|
474
|
+
suffix,
|
|
475
|
+
isWithInAWeek
|
|
476
|
+
}) => {
|
|
518
477
|
if (days > 7) {
|
|
519
478
|
return 'DD-MM-YYYY';
|
|
520
479
|
}
|
|
521
|
-
|
|
522
480
|
return '[less 7] DD-MM-YYYY';
|
|
523
481
|
},
|
|
524
482
|
ago: "ago",
|
|
@@ -528,7 +486,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
528
486
|
expect(tree).toMatchSnapshot();
|
|
529
487
|
});
|
|
530
488
|
it('Should display other later- less time', () => {
|
|
531
|
-
let ele = renderer.create(
|
|
489
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
532
490
|
i18n: {
|
|
533
491
|
today: 'today',
|
|
534
492
|
yesterday: 'yesterday'
|
|
@@ -549,19 +507,16 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
549
507
|
key: 'tomorrow',
|
|
550
508
|
params: ['hh', 'mm', 'ss']
|
|
551
509
|
},
|
|
552
|
-
others:
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
} = _ref14;
|
|
560
|
-
|
|
510
|
+
others: ({
|
|
511
|
+
years,
|
|
512
|
+
days,
|
|
513
|
+
hours,
|
|
514
|
+
minutes,
|
|
515
|
+
suffix
|
|
516
|
+
}) => {
|
|
561
517
|
if (days > 7) {
|
|
562
518
|
return 'DD-MM-YYYY';
|
|
563
519
|
}
|
|
564
|
-
|
|
565
520
|
return '[less 7] DD-MM-YYYY';
|
|
566
521
|
},
|
|
567
522
|
ago: "ago",
|
|
@@ -571,7 +526,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
571
526
|
expect(tree).toMatchSnapshot();
|
|
572
527
|
});
|
|
573
528
|
it('Should display other later- less time', () => {
|
|
574
|
-
let ele = renderer.create(
|
|
529
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
575
530
|
i18n: {
|
|
576
531
|
today: 'today',
|
|
577
532
|
yesterday: 'yesterday'
|
|
@@ -592,19 +547,16 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
592
547
|
key: 'tomorrow',
|
|
593
548
|
params: ['hh', 'mm', 'ss']
|
|
594
549
|
},
|
|
595
|
-
others:
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
} = _ref15;
|
|
603
|
-
|
|
550
|
+
others: ({
|
|
551
|
+
years,
|
|
552
|
+
days,
|
|
553
|
+
hours,
|
|
554
|
+
minutes,
|
|
555
|
+
suffix
|
|
556
|
+
}) => {
|
|
604
557
|
if (days > 7) {
|
|
605
558
|
return 'DD-MM-YYYY';
|
|
606
559
|
}
|
|
607
|
-
|
|
608
560
|
return '[less 7] DD-MM-YYYY';
|
|
609
561
|
},
|
|
610
562
|
ago: "ago",
|
|
@@ -614,7 +566,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
614
566
|
expect(tree).toMatchSnapshot();
|
|
615
567
|
});
|
|
616
568
|
it('Should display others', () => {
|
|
617
|
-
let ele = renderer.create(
|
|
569
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
618
570
|
i18n: {
|
|
619
571
|
today: 'today',
|
|
620
572
|
yesterday: 'yesterday'
|
|
@@ -635,20 +587,17 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
635
587
|
key: 'tomorrow',
|
|
636
588
|
params: ['hh', 'mm', 'ss']
|
|
637
589
|
},
|
|
638
|
-
others:
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
} = _ref16;
|
|
647
|
-
|
|
590
|
+
others: ({
|
|
591
|
+
years,
|
|
592
|
+
days,
|
|
593
|
+
hours,
|
|
594
|
+
minutes,
|
|
595
|
+
suffix,
|
|
596
|
+
isWithInAWeek
|
|
597
|
+
}) => {
|
|
648
598
|
if (days > 7) {
|
|
649
599
|
return 'DD-MM-YYYY';
|
|
650
600
|
}
|
|
651
|
-
|
|
652
601
|
return '[less 7] DD-MM-YYYY';
|
|
653
602
|
},
|
|
654
603
|
ago: "ago",
|
|
@@ -659,7 +608,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
659
608
|
});
|
|
660
609
|
it('Should display today1', () => {
|
|
661
610
|
let toDates = ['2016-10-24T05:55:28.000Z', '2016-10-24T06:55:28.000Z', '2016-10-24T04:55:28.000Z', '2016-10-25T05:55:28.000Z', '2016-10-25T04:55:28.000Z', '2016-10-25T06:55:28.000Z', '2016-10-26T05:55:28.000Z', '2016-10-26T04:55:28.000Z', '2016-10-26T06:55:28.000Z', '2016-10-23T05:55:28.000Z', '2016-10-23T04:55:28.000Z', '2016-10-23T06:55:28.000Z'];
|
|
662
|
-
let ele = renderer.create(
|
|
611
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
663
612
|
i18n: {
|
|
664
613
|
today: 'today',
|
|
665
614
|
yesterday: 'yesterday',
|
|
@@ -674,14 +623,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
674
623
|
key: i,
|
|
675
624
|
to: to,
|
|
676
625
|
toTimeZone: "Asia/Kolkata",
|
|
677
|
-
format: (
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
} = _ref17;
|
|
684
|
-
|
|
626
|
+
format: ({
|
|
627
|
+
years,
|
|
628
|
+
days,
|
|
629
|
+
months,
|
|
630
|
+
hours
|
|
631
|
+
}, pattern) => {
|
|
685
632
|
switch (pattern) {
|
|
686
633
|
case '000000':
|
|
687
634
|
case '000001':
|
|
@@ -690,27 +637,23 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
690
637
|
key: 'now'
|
|
691
638
|
};
|
|
692
639
|
break;
|
|
693
|
-
|
|
694
640
|
case '000010':
|
|
695
641
|
return {
|
|
696
642
|
key: 'support.1min'
|
|
697
643
|
};
|
|
698
644
|
break;
|
|
699
|
-
|
|
700
645
|
case '000020':
|
|
701
646
|
return {
|
|
702
647
|
key: 'support.nmins',
|
|
703
648
|
params: ['m']
|
|
704
649
|
};
|
|
705
650
|
break;
|
|
706
|
-
|
|
707
651
|
case '001000':
|
|
708
652
|
case '001100':
|
|
709
653
|
return {
|
|
710
654
|
key: 'support.1day'
|
|
711
655
|
};
|
|
712
656
|
break;
|
|
713
|
-
|
|
714
657
|
case '001200':
|
|
715
658
|
case '001201':
|
|
716
659
|
return {
|
|
@@ -727,7 +670,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
727
670
|
expect(tree).toMatchSnapshot();
|
|
728
671
|
});
|
|
729
672
|
it('Should display today later', () => {
|
|
730
|
-
let ele = renderer.create(
|
|
673
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
731
674
|
i18n: {
|
|
732
675
|
today: 'today',
|
|
733
676
|
yesterday: 'yesterday',
|
|
@@ -749,15 +692,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
749
692
|
key: 'tomorrow',
|
|
750
693
|
params: ['hh', 'mm', 'ss']
|
|
751
694
|
},
|
|
752
|
-
others:
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
} = _ref18;
|
|
759
|
-
return 'DD-MM-YYYY';
|
|
760
|
-
},
|
|
695
|
+
others: ({
|
|
696
|
+
years,
|
|
697
|
+
days,
|
|
698
|
+
hours,
|
|
699
|
+
minutes
|
|
700
|
+
}) => 'DD-MM-YYYY',
|
|
761
701
|
ago: "ago",
|
|
762
702
|
later: "later"
|
|
763
703
|
})));
|
|
@@ -765,7 +705,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
765
705
|
expect(tree).toMatchSnapshot();
|
|
766
706
|
});
|
|
767
707
|
it('Should display today ago', () => {
|
|
768
|
-
let ele = renderer.create(
|
|
708
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
769
709
|
i18n: {
|
|
770
710
|
today: 'today',
|
|
771
711
|
yesterday: 'yesterday',
|
|
@@ -789,15 +729,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
789
729
|
key: 'tomorrow',
|
|
790
730
|
params: ['hh', 'mm', 'ss']
|
|
791
731
|
},
|
|
792
|
-
others:
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
} = _ref19;
|
|
799
|
-
return 'DD-MM-YYYY';
|
|
800
|
-
},
|
|
732
|
+
others: ({
|
|
733
|
+
years,
|
|
734
|
+
days,
|
|
735
|
+
hours,
|
|
736
|
+
minutes
|
|
737
|
+
}) => 'DD-MM-YYYY',
|
|
801
738
|
ago: "ago",
|
|
802
739
|
later: "later"
|
|
803
740
|
})));
|
|
@@ -805,7 +742,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
805
742
|
expect(tree).toMatchSnapshot();
|
|
806
743
|
});
|
|
807
744
|
it('Should display years and days', () => {
|
|
808
|
-
let ele = renderer.create(
|
|
745
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
809
746
|
i18n: {
|
|
810
747
|
'nyear.ndays.ago': '{0} years {1} days ago',
|
|
811
748
|
yesterday: 'yesterday'
|
|
@@ -815,14 +752,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
815
752
|
from: "2017-10-25T05:55:28.000Z",
|
|
816
753
|
to: "2015-08-25T05:55:28.000Z",
|
|
817
754
|
toTimeZone: "Asia/Kolkata",
|
|
818
|
-
format: (
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
} = _ref20;
|
|
825
|
-
|
|
755
|
+
format: ({
|
|
756
|
+
years,
|
|
757
|
+
days,
|
|
758
|
+
months,
|
|
759
|
+
hours
|
|
760
|
+
}, pattern) => {
|
|
826
761
|
if (years > 1) {
|
|
827
762
|
return {
|
|
828
763
|
key: 'nyear.ndays',
|
|
@@ -837,7 +772,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
837
772
|
expect(tree).toMatchSnapshot();
|
|
838
773
|
});
|
|
839
774
|
it('Should display years and days1', () => {
|
|
840
|
-
let ele = renderer.create(
|
|
775
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
841
776
|
i18n: {
|
|
842
777
|
'nyear.ndays.later': '{0} years {1} days later',
|
|
843
778
|
yesterday: 'yesterday'
|
|
@@ -847,14 +782,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
847
782
|
from: "2015-08-25T05:55:28.000Z",
|
|
848
783
|
to: "2017-10-25T05:55:28.000Z",
|
|
849
784
|
toTimeZone: "Asia/Kolkata",
|
|
850
|
-
format: (
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
} = _ref21;
|
|
857
|
-
|
|
785
|
+
format: ({
|
|
786
|
+
years,
|
|
787
|
+
days,
|
|
788
|
+
months,
|
|
789
|
+
hours
|
|
790
|
+
}, pattern) => {
|
|
858
791
|
if (years > 1) {
|
|
859
792
|
return {
|
|
860
793
|
key: 'nyear.ndays',
|
|
@@ -869,7 +802,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
869
802
|
expect(tree).toMatchSnapshot();
|
|
870
803
|
});
|
|
871
804
|
it('Should display today key - user', () => {
|
|
872
|
-
let ele = renderer.create(
|
|
805
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
873
806
|
i18n: {
|
|
874
807
|
today: 'today',
|
|
875
808
|
yesterday: 'yesterday'
|
|
@@ -889,15 +822,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
889
822
|
key: 'tomorrow',
|
|
890
823
|
params: ['hh', 'mm', 'ss']
|
|
891
824
|
},
|
|
892
|
-
others:
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
} = _ref22;
|
|
899
|
-
return 'DD-MM-YYYY';
|
|
900
|
-
},
|
|
825
|
+
others: ({
|
|
826
|
+
years,
|
|
827
|
+
days,
|
|
828
|
+
hours,
|
|
829
|
+
minutes
|
|
830
|
+
}) => 'DD-MM-YYYY',
|
|
901
831
|
ago: "ago",
|
|
902
832
|
later: "later"
|
|
903
833
|
})));
|
|
@@ -905,7 +835,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
905
835
|
expect(tree).toMatchSnapshot();
|
|
906
836
|
});
|
|
907
837
|
it('Should display today later - user', () => {
|
|
908
|
-
let ele = renderer.create(
|
|
838
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
909
839
|
i18n: {
|
|
910
840
|
today: 'today',
|
|
911
841
|
yesterday: 'yesterday',
|
|
@@ -926,15 +856,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
926
856
|
key: 'tomorrow',
|
|
927
857
|
params: ['hh', 'mm', 'ss']
|
|
928
858
|
},
|
|
929
|
-
others:
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
} = _ref23;
|
|
936
|
-
return 'DD-MM-YYYY';
|
|
937
|
-
},
|
|
859
|
+
others: ({
|
|
860
|
+
years,
|
|
861
|
+
days,
|
|
862
|
+
hours,
|
|
863
|
+
minutes
|
|
864
|
+
}) => 'DD-MM-YYYY',
|
|
938
865
|
ago: "ago",
|
|
939
866
|
later: "later"
|
|
940
867
|
})));
|
|
@@ -942,7 +869,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
942
869
|
expect(tree).toMatchSnapshot();
|
|
943
870
|
});
|
|
944
871
|
it('Should display today ago - user', () => {
|
|
945
|
-
let ele = renderer.create(
|
|
872
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
946
873
|
i18n: {
|
|
947
874
|
today: 'today',
|
|
948
875
|
yesterday: 'yesterday',
|
|
@@ -964,15 +891,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
964
891
|
key: 'tomorrow',
|
|
965
892
|
params: ['hh', 'mm', 'ss']
|
|
966
893
|
},
|
|
967
|
-
others:
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
} = _ref24;
|
|
974
|
-
return 'DD-MM-YYYY';
|
|
975
|
-
},
|
|
894
|
+
others: ({
|
|
895
|
+
years,
|
|
896
|
+
days,
|
|
897
|
+
hours,
|
|
898
|
+
minutes
|
|
899
|
+
}) => 'DD-MM-YYYY',
|
|
976
900
|
ago: "ago",
|
|
977
901
|
later: "later"
|
|
978
902
|
})));
|
|
@@ -980,7 +904,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
980
904
|
expect(tree).toMatchSnapshot();
|
|
981
905
|
});
|
|
982
906
|
it('task due date set - today [hh:mm:AM/PM]', () => {
|
|
983
|
-
let ele = renderer.create(
|
|
907
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
984
908
|
i18n: {
|
|
985
909
|
today: 'today',
|
|
986
910
|
yesterday: 'yesterday',
|
|
@@ -1007,7 +931,6 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1007
931
|
},
|
|
1008
932
|
timeZone: "Asia/Kolkata"
|
|
1009
933
|
}, /*#__PURE__*/React.createElement(App, null)));
|
|
1010
|
-
|
|
1011
934
|
function App() {
|
|
1012
935
|
return /*#__PURE__*/React.createElement(UserTimeDiffFormat, {
|
|
1013
936
|
to: "2015-10-25T05:55:28.000Z",
|
|
@@ -1015,15 +938,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1015
938
|
today: '[today] hh:mm A',
|
|
1016
939
|
yesterday: 'dd:MM:YYYY hh:mm A',
|
|
1017
940
|
tomorrow: '[tommorrow] hh:mm A',
|
|
1018
|
-
others:
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
} = _ref25;
|
|
1025
|
-
return 'DD-MM-YYYY';
|
|
1026
|
-
},
|
|
941
|
+
others: ({
|
|
942
|
+
years,
|
|
943
|
+
days,
|
|
944
|
+
hours,
|
|
945
|
+
minutes
|
|
946
|
+
}) => 'DD-MM-YYYY',
|
|
1027
947
|
ago: "ago",
|
|
1028
948
|
later: "later",
|
|
1029
949
|
title: i18NProviderUtils.userDateFormat('2015-10-27T05:55:28.000Z', {}, '', 'later', true, (diffObj, pattern) => {
|
|
@@ -1107,7 +1027,9 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1107
1027
|
'0020': {
|
|
1108
1028
|
key: 'nhours',
|
|
1109
1029
|
params: ['hh']
|
|
1110
|
-
}
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
// '0000': 'support.label.just.now',
|
|
1111
1033
|
// '0001': 'support.1minute',
|
|
1112
1034
|
// '0002': 'support.nminutes',
|
|
1113
1035
|
// '0010': 'support.1hour',
|
|
@@ -1128,9 +1050,9 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1128
1050
|
// '2000': 'support.nyears',
|
|
1129
1051
|
// '2100': 'support.nyears.1day',
|
|
1130
1052
|
// '2200': 'support.nyears.ndays'
|
|
1131
|
-
|
|
1132
1053
|
};
|
|
1133
|
-
return getDateI18NString[pattern] ? getDateI18NString[pattern] : 'hh:mm A';
|
|
1054
|
+
return getDateI18NString[pattern] ? getDateI18NString[pattern] : 'hh:mm A';
|
|
1055
|
+
// console.log(pattern, '===========>>>>pattern');
|
|
1134
1056
|
// let { years, months, yDays: days, hours, minutes } = diffObj;
|
|
1135
1057
|
// if (years == 1 && days == 1) {
|
|
1136
1058
|
// return { key: 'year.day', pattern: ['YY', 'DD'] };
|
|
@@ -1170,12 +1092,11 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1170
1092
|
})
|
|
1171
1093
|
});
|
|
1172
1094
|
}
|
|
1173
|
-
|
|
1174
1095
|
let tree = ele.toJSON();
|
|
1175
1096
|
expect(tree).toMatchSnapshot();
|
|
1176
1097
|
});
|
|
1177
1098
|
it('task due date set - tomorrow [hh:mm:AM/PM]', () => {
|
|
1178
|
-
let ele = renderer.create(
|
|
1099
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
1179
1100
|
i18n: {
|
|
1180
1101
|
today: 'today',
|
|
1181
1102
|
yesterday: 'yesterday'
|
|
@@ -1187,15 +1108,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1187
1108
|
today: '[today] hh:mm A',
|
|
1188
1109
|
yesterday: 'dd:MM:YYYY hh:mm A',
|
|
1189
1110
|
tomorrow: '[tommorrow] hh:mm A',
|
|
1190
|
-
others:
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
} = _ref26;
|
|
1197
|
-
return 'DD-MM-YYYY';
|
|
1198
|
-
},
|
|
1111
|
+
others: ({
|
|
1112
|
+
years,
|
|
1113
|
+
days,
|
|
1114
|
+
hours,
|
|
1115
|
+
minutes
|
|
1116
|
+
}) => 'DD-MM-YYYY',
|
|
1199
1117
|
ago: "ago",
|
|
1200
1118
|
later: "later"
|
|
1201
1119
|
})));
|
|
@@ -1203,7 +1121,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1203
1121
|
expect(tree).toMatchSnapshot();
|
|
1204
1122
|
});
|
|
1205
1123
|
it('task due date set - yesterday dd:MM:YYYY hh:mm:A', () => {
|
|
1206
|
-
let ele = renderer.create(
|
|
1124
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
1207
1125
|
i18n: {
|
|
1208
1126
|
today: 'today',
|
|
1209
1127
|
yesterday: 'yesterday'
|
|
@@ -1215,15 +1133,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1215
1133
|
today: '[today] hh:mm A',
|
|
1216
1134
|
yesterday: 'DD/MM/YYYY hh:mm A',
|
|
1217
1135
|
tomorrow: '[tommorrow] hh:mm A',
|
|
1218
|
-
others:
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
} = _ref27;
|
|
1225
|
-
return 'DD-MM-YYYY';
|
|
1226
|
-
},
|
|
1136
|
+
others: ({
|
|
1137
|
+
years,
|
|
1138
|
+
days,
|
|
1139
|
+
hours,
|
|
1140
|
+
minutes
|
|
1141
|
+
}) => 'DD-MM-YYYY',
|
|
1227
1142
|
ago: "ago",
|
|
1228
1143
|
later: "later"
|
|
1229
1144
|
})));
|
|
@@ -1231,7 +1146,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1231
1146
|
expect(tree).toMatchSnapshot();
|
|
1232
1147
|
});
|
|
1233
1148
|
it('task due date set - overdue', () => {
|
|
1234
|
-
let ele = renderer.create(
|
|
1149
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
1235
1150
|
i18n: {
|
|
1236
1151
|
'overdue.ago': 'late by {0}'
|
|
1237
1152
|
},
|
|
@@ -1269,10 +1184,10 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1269
1184
|
})));
|
|
1270
1185
|
let tree = ele.toJSON();
|
|
1271
1186
|
expect(tree).toMatchSnapshot();
|
|
1272
|
-
});
|
|
1273
|
-
|
|
1187
|
+
});
|
|
1188
|
+
//2016-10-25T05:55:28.000Z
|
|
1274
1189
|
it('created time today', () => {
|
|
1275
|
-
let ele = renderer.create(
|
|
1190
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
1276
1191
|
i18n: {
|
|
1277
1192
|
'overdue.ago': 'late by {0}'
|
|
1278
1193
|
},
|
|
@@ -1282,15 +1197,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1282
1197
|
today: 'hh:mm A',
|
|
1283
1198
|
yesterday: 'DD/MM/YYYY hh:mm A',
|
|
1284
1199
|
tomorrow: '[tommorrow] hh:mm A',
|
|
1285
|
-
others:
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
} = _ref28;
|
|
1292
|
-
return 'DD-MM-YYYY';
|
|
1293
|
-
},
|
|
1200
|
+
others: ({
|
|
1201
|
+
years,
|
|
1202
|
+
days,
|
|
1203
|
+
hours,
|
|
1204
|
+
minutes
|
|
1205
|
+
}) => 'DD-MM-YYYY',
|
|
1294
1206
|
ago: "ago",
|
|
1295
1207
|
later: "later"
|
|
1296
1208
|
})));
|
|
@@ -1298,7 +1210,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1298
1210
|
expect(tree).toMatchSnapshot();
|
|
1299
1211
|
});
|
|
1300
1212
|
it('created time yesterday', () => {
|
|
1301
|
-
let ele = renderer.create(
|
|
1213
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
1302
1214
|
i18n: {
|
|
1303
1215
|
'overdue.ago': 'late by {0}'
|
|
1304
1216
|
},
|
|
@@ -1308,15 +1220,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1308
1220
|
today: 'hh:mm A',
|
|
1309
1221
|
yesterday: '[yesterday] hh:mm A',
|
|
1310
1222
|
tomorrow: '[tommorrow] hh:mm A',
|
|
1311
|
-
others:
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
} = _ref29;
|
|
1318
|
-
return 'DD-MM-YYYY';
|
|
1319
|
-
},
|
|
1223
|
+
others: ({
|
|
1224
|
+
years,
|
|
1225
|
+
days,
|
|
1226
|
+
hours,
|
|
1227
|
+
minutes
|
|
1228
|
+
}) => 'DD-MM-YYYY',
|
|
1320
1229
|
ago: "ago",
|
|
1321
1230
|
later: "later"
|
|
1322
1231
|
})));
|
|
@@ -1324,7 +1233,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1324
1233
|
expect(tree).toMatchSnapshot();
|
|
1325
1234
|
});
|
|
1326
1235
|
it('created time tomorrow', () => {
|
|
1327
|
-
let ele = renderer.create(
|
|
1236
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
1328
1237
|
i18n: {
|
|
1329
1238
|
'overdue.ago': 'late by {0}'
|
|
1330
1239
|
},
|
|
@@ -1334,15 +1243,12 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1334
1243
|
today: 'hh:mm A',
|
|
1335
1244
|
yesterday: '[yesterday] hh:mm A',
|
|
1336
1245
|
tomorrow: '[tommorrow] hh:mm A',
|
|
1337
|
-
others:
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
} = _ref30;
|
|
1344
|
-
return 'DD-MM-YYYY';
|
|
1345
|
-
},
|
|
1246
|
+
others: ({
|
|
1247
|
+
years,
|
|
1248
|
+
days,
|
|
1249
|
+
hours,
|
|
1250
|
+
minutes
|
|
1251
|
+
}) => 'DD-MM-YYYY',
|
|
1346
1252
|
ago: "ago",
|
|
1347
1253
|
later: "later"
|
|
1348
1254
|
})));
|
|
@@ -1350,7 +1256,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1350
1256
|
expect(tree).toMatchSnapshot();
|
|
1351
1257
|
});
|
|
1352
1258
|
it('created time within 7 days', () => {
|
|
1353
|
-
let ele = renderer.create(
|
|
1259
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
1354
1260
|
i18n: {
|
|
1355
1261
|
'overdue.ago': 'late by {0}',
|
|
1356
1262
|
'support.ndays.nhours.ago': '{0} days {1} hours ago',
|
|
@@ -1362,23 +1268,22 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1362
1268
|
today: 'hh:mm A',
|
|
1363
1269
|
yesterday: '[yesterday] hh:mm A',
|
|
1364
1270
|
tomorrow: '[tommorrow] hh:mm A',
|
|
1365
|
-
others:
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1271
|
+
others: ({
|
|
1272
|
+
years,
|
|
1273
|
+
months,
|
|
1274
|
+
days,
|
|
1275
|
+
hours,
|
|
1276
|
+
minutes,
|
|
1277
|
+
yDays
|
|
1278
|
+
}) => {
|
|
1279
|
+
years = years > 1 ? '2' : years;
|
|
1280
|
+
// months = diffObj1.months > 1 ? '2' : diffObj1.months;
|
|
1375
1281
|
//days = diffObj1.days > 1 ? '2' : diffObj1.days;
|
|
1376
|
-
|
|
1377
1282
|
days = yDays > 1 ? '2' : yDays;
|
|
1378
1283
|
hours = hours > 1 ? '2' : hours;
|
|
1379
|
-
minutes = minutes > 1 ? '2' : minutes;
|
|
1284
|
+
minutes = minutes > 1 ? '2' : minutes;
|
|
1285
|
+
//seconds = diffObj1.seconds > 1 ? '2' : diffObj1.seconds;
|
|
1380
1286
|
// let pattern = '' + years + months + days + hours + minutes + seconds;
|
|
1381
|
-
|
|
1382
1287
|
let count = 0;
|
|
1383
1288
|
let pattern = [years, days, hours, minutes].reduce((res, next) => {
|
|
1384
1289
|
if (count == 2) {
|
|
@@ -1389,7 +1294,6 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1389
1294
|
} else {
|
|
1390
1295
|
res = res + next;
|
|
1391
1296
|
}
|
|
1392
|
-
|
|
1393
1297
|
return res;
|
|
1394
1298
|
}, '');
|
|
1395
1299
|
let getDateI18NString = {
|
|
@@ -1415,7 +1319,6 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1415
1319
|
'2100': 'support.nyears.1day',
|
|
1416
1320
|
'2200': 'support.nyears.ndays'
|
|
1417
1321
|
};
|
|
1418
|
-
|
|
1419
1322
|
if (years == 0 && months == 0 && days < 7) {
|
|
1420
1323
|
return {
|
|
1421
1324
|
key: getDateI18NString[pattern],
|
|
@@ -1430,7 +1333,7 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1430
1333
|
expect(tree).toMatchSnapshot();
|
|
1431
1334
|
});
|
|
1432
1335
|
it('created time within pattern', () => {
|
|
1433
|
-
let ele = renderer.create(
|
|
1336
|
+
let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
|
|
1434
1337
|
i18n: {
|
|
1435
1338
|
'overdue.ago': 'late by {0}',
|
|
1436
1339
|
'support.ndays.nhours.ago': '{0} days {1} hours ago',
|
|
@@ -1439,15 +1342,14 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1439
1342
|
timeZone: "Asia/Kolkata"
|
|
1440
1343
|
}, /*#__PURE__*/React.createElement(UserTimeDiffFormat, {
|
|
1441
1344
|
to: "2016-10-19T06:55:28.000Z",
|
|
1442
|
-
format: (
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
} = _ref32;
|
|
1345
|
+
format: ({
|
|
1346
|
+
years,
|
|
1347
|
+
months,
|
|
1348
|
+
days,
|
|
1349
|
+
hours,
|
|
1350
|
+
minutes,
|
|
1351
|
+
yDays
|
|
1352
|
+
}, pattern) => {
|
|
1451
1353
|
let getDateI18NString = {
|
|
1452
1354
|
'0000': 'support.label.just.now',
|
|
1453
1355
|
'0001': 'support.1minute',
|
|
@@ -1471,7 +1373,6 @@ describe('UserTimeDiffFormat component', () => {
|
|
|
1471
1373
|
'2100': 'support.nyears.1day',
|
|
1472
1374
|
'2200': 'support.nyears.ndays'
|
|
1473
1375
|
};
|
|
1474
|
-
|
|
1475
1376
|
if (years == 0 && months == 0 && days < 7) {
|
|
1476
1377
|
return {
|
|
1477
1378
|
key: getDateI18NString[pattern],
|