@zohodesk/i18n 1.0.0-beta.3 → 1.0.0-beta.31

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.
Files changed (60) hide show
  1. package/README.md +120 -2
  2. package/es/I18NContext.js +1 -2
  3. package/es/components/DateTimeDiffFormat.js +192 -200
  4. package/es/components/FormatText.js +4 -25
  5. package/es/components/HOCI18N.js +33 -45
  6. package/es/components/I18N.js +48 -63
  7. package/es/components/I18NProvider.js +60 -85
  8. package/es/components/PluralFormat.js +29 -48
  9. package/es/components/UserTimeDiffFormat.js +65 -74
  10. package/es/components/__tests__/DateTimeDiffFormat.spec.js +868 -657
  11. package/es/components/__tests__/FormatText.spec.js +20 -17
  12. package/es/components/__tests__/HOCI18N.spec.js +18 -22
  13. package/es/components/__tests__/I18N.spec.js +20 -19
  14. package/es/components/__tests__/I18NProvider.spec.js +36 -45
  15. package/es/components/__tests__/PluralFormat.spec.js +20 -17
  16. package/es/components/__tests__/UserTimeDiffFormat.spec.js +1343 -1095
  17. package/es/index.js +2 -6
  18. package/es/utils/__tests__/jsxTranslations.spec.js +174 -0
  19. package/es/utils/index.js +592 -0
  20. package/es/utils/jsxTranslations.js +193 -0
  21. package/lib/I18NContext.js +6 -6
  22. package/lib/components/DateTimeDiffFormat.js +151 -123
  23. package/lib/components/FormatText.js +32 -22
  24. package/lib/components/HOCI18N.js +47 -23
  25. package/lib/components/I18N.js +62 -36
  26. package/lib/components/I18NProvider.js +85 -72
  27. package/lib/components/PluralFormat.js +42 -32
  28. package/lib/components/UserTimeDiffFormat.js +79 -56
  29. package/lib/components/__tests__/DateTimeDiffFormat.spec.js +815 -629
  30. package/lib/components/__tests__/FormatText.spec.js +23 -25
  31. package/lib/components/__tests__/HOCI18N.spec.js +26 -34
  32. package/lib/components/__tests__/I18N.spec.js +21 -26
  33. package/lib/components/__tests__/I18NProvider.spec.js +43 -51
  34. package/lib/components/__tests__/PluralFormat.spec.js +24 -28
  35. package/lib/components/__tests__/UserTimeDiffFormat.spec.js +1256 -1039
  36. package/lib/index.js +85 -110
  37. package/lib/utils/__tests__/jsxTranslations.spec.js +183 -0
  38. package/lib/utils/index.js +658 -0
  39. package/lib/utils/jsxTranslations.js +242 -0
  40. package/package.json +3 -2
  41. package/src/components/DateTimeDiffFormat.js +86 -55
  42. package/src/components/I18N.js +2 -0
  43. package/src/components/I18NProvider.js +44 -33
  44. package/src/components/UserTimeDiffFormat.js +24 -18
  45. package/src/index.js +7 -9
  46. package/src/utils/__tests__/jsxTranslations.spec.js +213 -0
  47. package/src/utils/index.js +632 -0
  48. package/src/utils/jsxTranslations.js +180 -0
  49. package/es/components/NewDateFormat.js +0 -50
  50. package/es/offset.js +0 -629
  51. package/es/timezones.js +0 -118
  52. package/es/utils.js +0 -621
  53. package/lib/components/NewDateFormat.js +0 -68
  54. package/lib/offset.js +0 -634
  55. package/lib/timezones.js +0 -129
  56. package/lib/utils.js +0 -651
  57. package/src/components/NewDateFormat.js +0 -60
  58. package/src/offset.js +0 -629
  59. package/src/timezones.js +0 -113
  60. package/src/utils.js +0 -648
@@ -2,720 +2,931 @@ import DateTimeDiffFormat from '../DateTimeDiffFormat';
2
2
  import I18NProvider from '../I18NProvider';
3
3
  import React from 'react';
4
4
  import renderer from 'react-test-renderer';
5
-
6
- var tzData = {
5
+ let tzData = {
7
6
  offsets: [154, 180],
8
7
  untils: [1013911200000, null]
9
8
  };
10
-
11
- var fromTzData = tzData,
9
+ let fromTzData = tzData,
12
10
  toTzData = tzData;
11
+ describe('DateTimeDiffFormat component', () => {
12
+ it('Should display yesterday - with same time', () => {
13
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
14
+ i18n: {
15
+ today: 'today',
16
+ yesterday: 'yesterday'
17
+ }
18
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
19
+ from: "2016-10-25T06:55:28.000Z",
20
+ fromTzData: fromTzData,
21
+ to: "2016-10-24T05:55:28.000Z",
22
+ toTzData: toTzData,
23
+ today: {
24
+ key: 'today',
25
+ params: ['hh', 'mm', 'ss']
26
+ },
27
+ yesterday: {
28
+ key: 'yesterday',
29
+ params: ['hh', 'mm', 'ss']
30
+ },
31
+ tomorrow: {
32
+ key: 'tomorrow',
33
+ params: ['hh', 'mm', 'ss']
34
+ },
35
+ others: _ref => {
36
+ let {
37
+ years,
38
+ days,
39
+ hours,
40
+ minutes
41
+ } = _ref;
13
42
 
14
- describe('DateTimeDiffFormat component', function () {
15
- it('Should display yesterday - with same time', function () {
16
- var ele = renderer.create(React.createElement(
17
- I18NProvider,
18
- { i18n: { today: 'today', yesterday: 'yesterday' } },
19
- React.createElement(DateTimeDiffFormat, {
20
- from: '2016-10-25T06:55:28.000Z',
21
- fromTzData: fromTzData,
22
- to: '2016-10-24T05:55:28.000Z',
23
- toTzData: toTzData,
24
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
25
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
26
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
27
- others: function others(_ref) {
28
- var years = _ref.years,
29
- days = _ref.days,
30
- hours = _ref.hours,
31
- minutes = _ref.minutes;
32
-
33
- if (days > 7) {
34
- return 'DD-MM-YYYY';
35
- }
36
- return getDateKeyWithParam(years, days, hours, minutes);
37
- },
38
- ago: 'ago',
39
- later: 'later'
40
- })
41
- ));
42
- var tree = ele.toJSON();
43
+ if (days > 7) {
44
+ return 'DD-MM-YYYY';
45
+ }
46
+
47
+ return getDateKeyWithParam(years, days, hours, minutes);
48
+ },
49
+ ago: "ago",
50
+ later: "later"
51
+ })));
52
+ let tree = ele.toJSON();
43
53
  expect(tree).toMatchSnapshot();
44
54
  });
45
- it('Should display yesterday - less than 24 hour', function () {
46
- var ele = renderer.create(React.createElement(
47
- I18NProvider,
48
- { i18n: { today: 'today', yesterday: 'yesterday' } },
49
- React.createElement(DateTimeDiffFormat, {
50
- from: '2016-10-25T05:55:28.000Z',
51
- fromTzData: fromTzData,
52
- to: '2016-10-24T06:55:28.000Z',
53
- toTzData: toTzData,
54
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
55
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
56
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
57
- others: function others(_ref2) {
58
- var years = _ref2.years,
59
- days = _ref2.days,
60
- hours = _ref2.hours,
61
- minutes = _ref2.minutes;
62
-
63
- if (days > 7) {
64
- return 'DD-MM-YYYY';
65
- }
66
- return getDateKeyWithParam(years, days, hours, minutes);
67
- },
68
- ago: 'ago',
69
- later: 'later'
70
- })
71
- ));
72
- var tree = ele.toJSON();
55
+ it('Should display yesterday - less than 24 hour', () => {
56
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
57
+ i18n: {
58
+ today: 'today',
59
+ yesterday: 'yesterday'
60
+ }
61
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
62
+ from: "2016-10-25T05:55:28.000Z",
63
+ fromTzData: fromTzData,
64
+ to: "2016-10-24T06:55:28.000Z",
65
+ toTzData: toTzData,
66
+ today: {
67
+ key: 'today',
68
+ params: ['hh', 'mm', 'ss']
69
+ },
70
+ yesterday: {
71
+ key: 'yesterday',
72
+ params: ['hh', 'mm', 'ss']
73
+ },
74
+ tomorrow: {
75
+ key: 'tomorrow',
76
+ params: ['hh', 'mm', 'ss']
77
+ },
78
+ others: _ref2 => {
79
+ let {
80
+ years,
81
+ days,
82
+ hours,
83
+ minutes
84
+ } = _ref2;
85
+
86
+ if (days > 7) {
87
+ return 'DD-MM-YYYY';
88
+ }
89
+
90
+ return getDateKeyWithParam(years, days, hours, minutes);
91
+ },
92
+ ago: "ago",
93
+ later: "later"
94
+ })));
95
+ let tree = ele.toJSON();
73
96
  expect(tree).toMatchSnapshot();
74
97
  });
75
- it('Should display yesterday - greater than 24 hour', function () {
76
- var ele = renderer.create(React.createElement(
77
- I18NProvider,
78
- { i18n: { today: 'today', yesterday: 'yesterday' } },
79
- React.createElement(DateTimeDiffFormat, {
80
- from: '2016-10-25T05:55:28.000Z',
81
- fromTzData: fromTzData,
82
- to: '2016-10-24T04:55:28.000Z',
83
- toTzData: toTzData,
84
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
85
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
86
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
87
- others: function others(_ref3) {
88
- var years = _ref3.years,
89
- days = _ref3.days,
90
- hours = _ref3.hours,
91
- minutes = _ref3.minutes;
92
-
93
- if (days > 7) {
94
- return 'DD-MM-YYYY';
95
- }
96
- return getDateKeyWithParam(years, days, hours, minutes);
97
- },
98
- ago: 'ago',
99
- later: 'later'
100
- })
101
- ));
102
- var tree = ele.toJSON();
98
+ it('Should display yesterday - greater than 24 hour', () => {
99
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
100
+ i18n: {
101
+ today: 'today',
102
+ yesterday: 'yesterday'
103
+ }
104
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
105
+ from: "2016-10-25T05:55:28.000Z",
106
+ fromTzData: fromTzData,
107
+ to: "2016-10-24T04:55:28.000Z",
108
+ toTzData: toTzData,
109
+ today: {
110
+ key: 'today',
111
+ params: ['hh', 'mm', 'ss']
112
+ },
113
+ yesterday: {
114
+ key: 'yesterday',
115
+ params: ['hh', 'mm', 'ss']
116
+ },
117
+ tomorrow: {
118
+ key: 'tomorrow',
119
+ params: ['hh', 'mm', 'ss']
120
+ },
121
+ others: _ref3 => {
122
+ let {
123
+ years,
124
+ days,
125
+ hours,
126
+ minutes
127
+ } = _ref3;
128
+
129
+ if (days > 7) {
130
+ return 'DD-MM-YYYY';
131
+ }
132
+
133
+ return getDateKeyWithParam(years, days, hours, minutes);
134
+ },
135
+ ago: "ago",
136
+ later: "later"
137
+ })));
138
+ let tree = ele.toJSON();
103
139
  expect(tree).toMatchSnapshot();
104
140
  });
105
- it('Should display today key - same time', function () {
106
- var ele = renderer.create(React.createElement(
107
- I18NProvider,
108
- { i18n: { today: 'today', yesterday: 'yesterday' } },
109
- React.createElement(DateTimeDiffFormat, {
110
- from: '2016-10-25T05:55:28.000Z',
111
- fromTzData: fromTzData,
112
- to: '2016-10-25T05:55:28.000Z',
113
- toTzData: toTzData,
114
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
115
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
116
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
117
- others: function others(_ref4) {
118
- var years = _ref4.years,
119
- days = _ref4.days,
120
- hours = _ref4.hours,
121
- minutes = _ref4.minutes;
122
-
123
- if (days > 7) {
124
- return 'DD-MM-YYYY';
125
- }
126
- return getDateKeyWithParam(years, days, hours, minutes);
127
- },
128
- ago: 'ago',
129
- later: 'later'
130
- })
131
- ));
132
- var tree = ele.toJSON();
141
+ it('Should display today key - same time', () => {
142
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
143
+ i18n: {
144
+ today: 'today',
145
+ yesterday: 'yesterday'
146
+ }
147
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
148
+ from: "2016-10-25T05:55:28.000Z",
149
+ fromTzData: fromTzData,
150
+ to: "2016-10-25T05:55:28.000Z",
151
+ toTzData: toTzData,
152
+ today: {
153
+ key: 'today',
154
+ params: ['hh', 'mm', 'ss']
155
+ },
156
+ yesterday: {
157
+ key: 'yesterday',
158
+ params: ['hh', 'mm', 'ss']
159
+ },
160
+ tomorrow: {
161
+ key: 'tomorrow',
162
+ params: ['hh', 'mm', 'ss']
163
+ },
164
+ others: _ref4 => {
165
+ let {
166
+ years,
167
+ days,
168
+ hours,
169
+ minutes
170
+ } = _ref4;
171
+
172
+ if (days > 7) {
173
+ return 'DD-MM-YYYY';
174
+ }
175
+
176
+ return getDateKeyWithParam(years, days, hours, minutes);
177
+ },
178
+ ago: "ago",
179
+ later: "later"
180
+ })));
181
+ let tree = ele.toJSON();
133
182
  expect(tree).toMatchSnapshot();
134
183
  });
184
+ it('Should display today key - less than 24 hour', () => {
185
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
186
+ i18n: {
187
+ today: 'today',
188
+ yesterday: 'yesterday'
189
+ }
190
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
191
+ from: "2016-10-25T05:55:28.000Z",
192
+ fromTzData: fromTzData,
193
+ to: "2016-10-25T04:55:28.000Z",
194
+ toTzData: toTzData,
195
+ today: {
196
+ key: 'today',
197
+ params: ['hh', 'mm', 'ss']
198
+ },
199
+ yesterday: {
200
+ key: 'yesterday',
201
+ params: ['hh', 'mm', 'ss']
202
+ },
203
+ tomorrow: {
204
+ key: 'tomorrow',
205
+ params: ['hh', 'mm', 'ss']
206
+ },
207
+ others: _ref5 => {
208
+ let {
209
+ years,
210
+ days,
211
+ hours,
212
+ minutes
213
+ } = _ref5;
135
214
 
136
- it('Should display today key - less than 24 hour', function () {
137
- var ele = renderer.create(React.createElement(
138
- I18NProvider,
139
- { i18n: { today: 'today', yesterday: 'yesterday' } },
140
- React.createElement(DateTimeDiffFormat, {
141
- from: '2016-10-25T05:55:28.000Z',
142
- fromTzData: fromTzData,
143
- to: '2016-10-25T04:55:28.000Z',
144
- toTzData: toTzData,
145
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
146
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
147
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
148
- others: function others(_ref5) {
149
- var years = _ref5.years,
150
- days = _ref5.days,
151
- hours = _ref5.hours,
152
- minutes = _ref5.minutes;
153
-
154
- if (days > 7) {
155
- return 'DD-MM-YYYY';
156
- }
157
- return getDateKeyWithParam(years, days, hours, minutes);
158
- },
159
- ago: 'ago',
160
- later: 'later'
161
- })
162
- ));
163
- var tree = ele.toJSON();
215
+ if (days > 7) {
216
+ return 'DD-MM-YYYY';
217
+ }
218
+
219
+ return getDateKeyWithParam(years, days, hours, minutes);
220
+ },
221
+ ago: "ago",
222
+ later: "later"
223
+ })));
224
+ let tree = ele.toJSON();
164
225
  expect(tree).toMatchSnapshot();
165
226
  });
166
- it('Should display today key - greater than 24 hour', function () {
167
- var ele = renderer.create(React.createElement(
168
- I18NProvider,
169
- { i18n: { today: 'today', yesterday: 'yesterday' } },
170
- React.createElement(DateTimeDiffFormat, {
171
- from: '2016-10-25T05:55:28.000Z',
172
- fromTzData: fromTzData,
173
- to: '2016-10-25T06:55:28.000Z',
174
- toTzData: toTzData,
175
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
176
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
177
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
178
- others: function others(_ref6) {
179
- var years = _ref6.years,
180
- days = _ref6.days,
181
- hours = _ref6.hours,
182
- minutes = _ref6.minutes;
183
-
184
- if (days > 7) {
185
- return 'DD-MM-YYYY';
186
- }
187
- return getDateKeyWithParam(years, days, hours, minutes);
188
- },
189
- ago: 'ago',
190
- later: 'later'
191
- })
192
- ));
193
- var tree = ele.toJSON();
227
+ it('Should display today key - greater than 24 hour', () => {
228
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
229
+ i18n: {
230
+ today: 'today',
231
+ yesterday: 'yesterday'
232
+ }
233
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
234
+ from: "2016-10-25T05:55:28.000Z",
235
+ fromTzData: fromTzData,
236
+ to: "2016-10-25T06:55:28.000Z",
237
+ toTzData: toTzData,
238
+ today: {
239
+ key: 'today',
240
+ params: ['hh', 'mm', 'ss']
241
+ },
242
+ yesterday: {
243
+ key: 'yesterday',
244
+ params: ['hh', 'mm', 'ss']
245
+ },
246
+ tomorrow: {
247
+ key: 'tomorrow',
248
+ params: ['hh', 'mm', 'ss']
249
+ },
250
+ others: _ref6 => {
251
+ let {
252
+ years,
253
+ days,
254
+ hours,
255
+ minutes
256
+ } = _ref6;
257
+
258
+ if (days > 7) {
259
+ return 'DD-MM-YYYY';
260
+ }
261
+
262
+ return getDateKeyWithParam(years, days, hours, minutes);
263
+ },
264
+ ago: "ago",
265
+ later: "later"
266
+ })));
267
+ let tree = ele.toJSON();
194
268
  expect(tree).toMatchSnapshot();
195
269
  });
196
- it('Should display tomorrow key - same time', function () {
197
- var ele = renderer.create(React.createElement(
198
- I18NProvider,
199
- { i18n: { today: 'today', yesterday: 'yesterday' } },
200
- React.createElement(DateTimeDiffFormat, {
201
- from: '2016-10-25T05:55:28.000Z',
202
- fromTzData: fromTzData,
203
- to: '2016-10-26T05:55:28.000Z',
204
- toTzData: toTzData,
205
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
206
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
207
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
208
- others: function others(_ref7) {
209
- var years = _ref7.years,
210
- days = _ref7.days,
211
- hours = _ref7.hours,
212
- minutes = _ref7.minutes;
213
-
214
- if (days > 7) {
215
- return 'DD-MM-YYYY';
216
- }
217
- return getDateKeyWithParam(years, days, hours, minutes);
218
- },
219
- ago: 'ago',
220
- later: 'later'
221
- })
222
- ));
223
- var tree = ele.toJSON();
270
+ it('Should display tomorrow key - same time', () => {
271
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
272
+ i18n: {
273
+ today: 'today',
274
+ yesterday: 'yesterday'
275
+ }
276
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
277
+ from: "2016-10-25T05:55:28.000Z",
278
+ fromTzData: fromTzData,
279
+ to: "2016-10-26T05:55:28.000Z",
280
+ toTzData: toTzData,
281
+ today: {
282
+ key: 'today',
283
+ params: ['hh', 'mm', 'ss']
284
+ },
285
+ yesterday: {
286
+ key: 'yesterday',
287
+ params: ['hh', 'mm', 'ss']
288
+ },
289
+ tomorrow: {
290
+ key: 'tomorrow',
291
+ params: ['hh', 'mm', 'ss']
292
+ },
293
+ others: _ref7 => {
294
+ let {
295
+ years,
296
+ days,
297
+ hours,
298
+ minutes
299
+ } = _ref7;
300
+
301
+ if (days > 7) {
302
+ return 'DD-MM-YYYY';
303
+ }
304
+
305
+ return getDateKeyWithParam(years, days, hours, minutes);
306
+ },
307
+ ago: "ago",
308
+ later: "later"
309
+ })));
310
+ let tree = ele.toJSON();
224
311
  expect(tree).toMatchSnapshot();
225
312
  });
226
- it('Should display tomorrow key - less than 24 hour', function () {
227
- var ele = renderer.create(React.createElement(
228
- I18NProvider,
229
- { i18n: { today: 'today', yesterday: 'yesterday' } },
230
- React.createElement(DateTimeDiffFormat, {
231
- from: '2016-10-25T05:55:28.000Z',
232
- fromTzData: fromTzData,
233
- to: '2016-10-26T04:55:28.000Z',
234
- toTzData: toTzData,
235
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
236
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
237
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
238
- others: function others(_ref8) {
239
- var years = _ref8.years,
240
- days = _ref8.days,
241
- hours = _ref8.hours,
242
- minutes = _ref8.minutes;
243
-
244
- if (days > 7) {
245
- return 'DD-MM-YYYY';
246
- }
247
- return getDateKeyWithParam(years, days, hours, minutes);
248
- },
249
- ago: 'ago',
250
- later: 'later'
251
- })
252
- ));
253
- var tree = ele.toJSON();
313
+ it('Should display tomorrow key - less than 24 hour', () => {
314
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
315
+ i18n: {
316
+ today: 'today',
317
+ yesterday: 'yesterday'
318
+ }
319
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
320
+ from: "2016-10-25T05:55:28.000Z",
321
+ fromTzData: fromTzData,
322
+ to: "2016-10-26T04:55:28.000Z",
323
+ toTzData: toTzData,
324
+ today: {
325
+ key: 'today',
326
+ params: ['hh', 'mm', 'ss']
327
+ },
328
+ yesterday: {
329
+ key: 'yesterday',
330
+ params: ['hh', 'mm', 'ss']
331
+ },
332
+ tomorrow: {
333
+ key: 'tomorrow',
334
+ params: ['hh', 'mm', 'ss']
335
+ },
336
+ others: _ref8 => {
337
+ let {
338
+ years,
339
+ days,
340
+ hours,
341
+ minutes
342
+ } = _ref8;
343
+
344
+ if (days > 7) {
345
+ return 'DD-MM-YYYY';
346
+ }
347
+
348
+ return getDateKeyWithParam(years, days, hours, minutes);
349
+ },
350
+ ago: "ago",
351
+ later: "later"
352
+ })));
353
+ let tree = ele.toJSON();
254
354
  expect(tree).toMatchSnapshot();
255
355
  });
256
- it('Should display tomorrow key - greater than 24 hour', function () {
257
- var ele = renderer.create(React.createElement(
258
- I18NProvider,
259
- { i18n: { today: 'today', yesterday: 'yesterday' } },
260
- React.createElement(DateTimeDiffFormat, {
261
- from: '2016-10-25T05:55:28.000Z',
262
- fromTzData: fromTzData,
263
- to: '2016-10-26T06:55:28.000Z',
264
- toTzData: toTzData,
265
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
266
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
267
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
268
- others: function others(_ref9) {
269
- var years = _ref9.years,
270
- days = _ref9.days,
271
- hours = _ref9.hours,
272
- minutes = _ref9.minutes;
273
-
274
- if (days > 7) {
275
- return 'DD-MM-YYYY';
276
- }
277
- return getDateKeyWithParam(years, days, hours, minutes);
278
- },
279
- ago: 'ago',
280
- later: 'later'
281
- })
282
- ));
283
- var tree = ele.toJSON();
356
+ it('Should display tomorrow key - greater than 24 hour', () => {
357
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
358
+ i18n: {
359
+ today: 'today',
360
+ yesterday: 'yesterday'
361
+ }
362
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
363
+ from: "2016-10-25T05:55:28.000Z",
364
+ fromTzData: fromTzData,
365
+ to: "2016-10-26T06:55:28.000Z",
366
+ toTzData: toTzData,
367
+ today: {
368
+ key: 'today',
369
+ params: ['hh', 'mm', 'ss']
370
+ },
371
+ yesterday: {
372
+ key: 'yesterday',
373
+ params: ['hh', 'mm', 'ss']
374
+ },
375
+ tomorrow: {
376
+ key: 'tomorrow',
377
+ params: ['hh', 'mm', 'ss']
378
+ },
379
+ others: _ref9 => {
380
+ let {
381
+ years,
382
+ days,
383
+ hours,
384
+ minutes
385
+ } = _ref9;
386
+
387
+ if (days > 7) {
388
+ return 'DD-MM-YYYY';
389
+ }
390
+
391
+ return getDateKeyWithParam(years, days, hours, minutes);
392
+ },
393
+ ago: "ago",
394
+ later: "later"
395
+ })));
396
+ let tree = ele.toJSON();
284
397
  expect(tree).toMatchSnapshot();
285
398
  });
286
- it('Should display other - same time', function () {
287
- var ele = renderer.create(React.createElement(
288
- I18NProvider,
289
- { i18n: { today: 'today', yesterday: 'yesterday' } },
290
- React.createElement(DateTimeDiffFormat, {
291
- from: '2016-10-25T05:55:28.000Z',
292
- fromTzData: fromTzData,
293
- to: '2016-10-23T05:55:28.000Z',
294
- toTzData: toTzData,
295
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
296
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
297
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
298
- others: function others(_ref10) {
299
- var years = _ref10.years,
300
- days = _ref10.days,
301
- hours = _ref10.hours,
302
- minutes = _ref10.minutes,
303
- suffix = _ref10.suffix;
304
-
305
- if (days > 7) {
306
- return 'DD-MM-YYYY';
307
- }
308
- return '[less 7] DD-MM-YYYY';
309
- },
310
- ago: 'ago',
311
- later: 'later'
312
- })
313
- ));
314
- var tree = ele.toJSON();
399
+ it('Should display other - same time', () => {
400
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
401
+ i18n: {
402
+ today: 'today',
403
+ yesterday: 'yesterday'
404
+ }
405
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
406
+ from: "2016-10-25T05:55:28.000Z",
407
+ fromTzData: fromTzData,
408
+ to: "2016-10-23T05:55:28.000Z",
409
+ toTzData: toTzData,
410
+ today: {
411
+ key: 'today',
412
+ params: ['hh', 'mm', 'ss']
413
+ },
414
+ yesterday: {
415
+ key: 'yesterday',
416
+ params: ['hh', 'mm', 'ss']
417
+ },
418
+ tomorrow: {
419
+ key: 'tomorrow',
420
+ params: ['hh', 'mm', 'ss']
421
+ },
422
+ others: _ref10 => {
423
+ let {
424
+ years,
425
+ days,
426
+ hours,
427
+ minutes,
428
+ suffix
429
+ } = _ref10;
430
+
431
+ if (days > 7) {
432
+ return 'DD-MM-YYYY';
433
+ }
434
+
435
+ return '[less 7] DD-MM-YYYY';
436
+ },
437
+ ago: "ago",
438
+ later: "later"
439
+ })));
440
+ let tree = ele.toJSON();
315
441
  expect(tree).toMatchSnapshot();
316
442
  });
317
- it('Should display other - greater time', function () {
318
- var ele = renderer.create(React.createElement(
319
- I18NProvider,
320
- { i18n: { today: 'today', yesterday: 'yesterday' } },
321
- React.createElement(DateTimeDiffFormat, {
322
- from: '2016-10-25T05:55:28.000Z',
323
- fromTzData: fromTzData,
324
- to: '2016-10-23T06:55:28.000Z',
325
- toTzData: toTzData,
326
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
327
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
328
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
329
- others: function others(_ref11) {
330
- var years = _ref11.years,
331
- days = _ref11.days,
332
- hours = _ref11.hours,
333
- minutes = _ref11.minutes,
334
- suffix = _ref11.suffix;
335
-
336
- if (days > 7) {
337
- return 'DD-MM-YYYY';
338
- }
339
- return '[less 7] DD-MM-YYYY';
340
- },
341
- ago: 'ago',
342
- later: 'later'
343
- })
344
- ));
345
- var tree = ele.toJSON();
443
+ it('Should display other - greater time', () => {
444
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
445
+ i18n: {
446
+ today: 'today',
447
+ yesterday: 'yesterday'
448
+ }
449
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
450
+ from: "2016-10-25T05:55:28.000Z",
451
+ fromTzData: fromTzData,
452
+ to: "2016-10-23T06:55:28.000Z",
453
+ toTzData: toTzData,
454
+ today: {
455
+ key: 'today',
456
+ params: ['hh', 'mm', 'ss']
457
+ },
458
+ yesterday: {
459
+ key: 'yesterday',
460
+ params: ['hh', 'mm', 'ss']
461
+ },
462
+ tomorrow: {
463
+ key: 'tomorrow',
464
+ params: ['hh', 'mm', 'ss']
465
+ },
466
+ others: _ref11 => {
467
+ let {
468
+ years,
469
+ days,
470
+ hours,
471
+ minutes,
472
+ suffix
473
+ } = _ref11;
474
+
475
+ if (days > 7) {
476
+ return 'DD-MM-YYYY';
477
+ }
478
+
479
+ return '[less 7] DD-MM-YYYY';
480
+ },
481
+ ago: "ago",
482
+ later: "later"
483
+ })));
484
+ let tree = ele.toJSON();
346
485
  expect(tree).toMatchSnapshot();
347
486
  });
348
- it('Should display other - less time', function () {
349
- var ele = renderer.create(React.createElement(
350
- I18NProvider,
351
- { i18n: { today: 'today', yesterday: 'yesterday' } },
352
- React.createElement(DateTimeDiffFormat, {
353
- from: '2016-10-25T05:55:28.000Z',
354
- fromTzData: fromTzData,
355
- to: '2016-10-23T04:55:28.000Z',
356
- toTzData: toTzData,
357
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
358
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
359
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
360
- others: function others(_ref12) {
361
- var years = _ref12.years,
362
- days = _ref12.days,
363
- hours = _ref12.hours,
364
- minutes = _ref12.minutes,
365
- suffix = _ref12.suffix;
366
-
367
- if (days > 7) {
368
- return 'DD-MM-YYYY';
369
- }
370
- return '[less 7] DD-MM-YYYY';
371
- },
372
- ago: 'ago',
373
- later: 'later'
374
- })
375
- ));
376
- var tree = ele.toJSON();
487
+ it('Should display other - less time', () => {
488
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
489
+ i18n: {
490
+ today: 'today',
491
+ yesterday: 'yesterday'
492
+ }
493
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
494
+ from: "2016-10-25T05:55:28.000Z",
495
+ fromTzData: fromTzData,
496
+ to: "2016-10-23T04:55:28.000Z",
497
+ toTzData: toTzData,
498
+ today: {
499
+ key: 'today',
500
+ params: ['hh', 'mm', 'ss']
501
+ },
502
+ yesterday: {
503
+ key: 'yesterday',
504
+ params: ['hh', 'mm', 'ss']
505
+ },
506
+ tomorrow: {
507
+ key: 'tomorrow',
508
+ params: ['hh', 'mm', 'ss']
509
+ },
510
+ others: _ref12 => {
511
+ let {
512
+ years,
513
+ days,
514
+ hours,
515
+ minutes,
516
+ suffix
517
+ } = _ref12;
518
+
519
+ if (days > 7) {
520
+ return 'DD-MM-YYYY';
521
+ }
522
+
523
+ return '[less 7] DD-MM-YYYY';
524
+ },
525
+ ago: "ago",
526
+ later: "later"
527
+ })));
528
+ let tree = ele.toJSON();
377
529
  expect(tree).toMatchSnapshot();
378
530
  });
379
- it('Should display other later- same time', function () {
380
- var ele = renderer.create(React.createElement(
381
- I18NProvider,
382
- { i18n: { today: 'today', yesterday: 'yesterday' } },
383
- React.createElement(DateTimeDiffFormat, {
384
- from: '2016-10-25T05:55:28.000Z',
385
- fromTzData: fromTzData,
386
- to: '2016-10-27T05:55:28.000Z',
387
- toTzData: toTzData,
388
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
389
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
390
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
391
- others: function others(_ref13) {
392
- var years = _ref13.years,
393
- days = _ref13.days,
394
- hours = _ref13.hours,
395
- minutes = _ref13.minutes,
396
- suffix = _ref13.suffix,
397
- isWithInAWeek = _ref13.isWithInAWeek;
398
-
399
- if (days > 7) {
400
- return 'DD-MM-YYYY';
401
- }
402
- return '[less 7] DD-MM-YYYY';
403
- },
404
- ago: 'ago',
405
- later: 'later'
406
- })
407
- ));
408
- var tree = ele.toJSON();
531
+ it('Should display other later- same time', () => {
532
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
533
+ i18n: {
534
+ today: 'today',
535
+ yesterday: 'yesterday'
536
+ }
537
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
538
+ from: "2016-10-25T05:55:28.000Z",
539
+ fromTzData: fromTzData,
540
+ to: "2016-10-27T05:55:28.000Z",
541
+ toTzData: toTzData,
542
+ today: {
543
+ key: 'today',
544
+ params: ['hh', 'mm', 'ss']
545
+ },
546
+ yesterday: {
547
+ key: 'yesterday',
548
+ params: ['hh', 'mm', 'ss']
549
+ },
550
+ tomorrow: {
551
+ key: 'tomorrow',
552
+ params: ['hh', 'mm', 'ss']
553
+ },
554
+ others: _ref13 => {
555
+ let {
556
+ years,
557
+ days,
558
+ hours,
559
+ minutes,
560
+ suffix,
561
+ isWithInAWeek
562
+ } = _ref13;
563
+
564
+ if (days > 7) {
565
+ return 'DD-MM-YYYY';
566
+ }
567
+
568
+ return '[less 7] DD-MM-YYYY';
569
+ },
570
+ ago: "ago",
571
+ later: "later"
572
+ })));
573
+ let tree = ele.toJSON();
409
574
  expect(tree).toMatchSnapshot();
410
575
  });
411
- it('Should display other later- less time', function () {
412
- var ele = renderer.create(React.createElement(
413
- I18NProvider,
414
- { i18n: { today: 'today', yesterday: 'yesterday' } },
415
- React.createElement(DateTimeDiffFormat, {
416
- from: '2016-10-25T05:55:28.000Z',
417
- fromTzData: fromTzData,
418
- to: '2016-10-27T06:55:28.000Z',
419
- toTzData: toTzData,
420
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
421
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
422
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
423
- others: function others(_ref14) {
424
- var years = _ref14.years,
425
- days = _ref14.days,
426
- hours = _ref14.hours,
427
- minutes = _ref14.minutes,
428
- suffix = _ref14.suffix;
429
-
430
- if (days > 7) {
431
- return 'DD-MM-YYYY';
432
- }
433
- return '[less 7] DD-MM-YYYY';
434
- },
435
- ago: 'ago',
436
- later: 'later'
437
- })
438
- ));
439
- var tree = ele.toJSON();
576
+ it('Should display other later- less time', () => {
577
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
578
+ i18n: {
579
+ today: 'today',
580
+ yesterday: 'yesterday'
581
+ }
582
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
583
+ from: "2016-10-25T05:55:28.000Z",
584
+ fromTzData: fromTzData,
585
+ to: "2016-10-27T06:55:28.000Z",
586
+ toTzData: toTzData,
587
+ today: {
588
+ key: 'today',
589
+ params: ['hh', 'mm', 'ss']
590
+ },
591
+ yesterday: {
592
+ key: 'yesterday',
593
+ params: ['hh', 'mm', 'ss']
594
+ },
595
+ tomorrow: {
596
+ key: 'tomorrow',
597
+ params: ['hh', 'mm', 'ss']
598
+ },
599
+ others: _ref14 => {
600
+ let {
601
+ years,
602
+ days,
603
+ hours,
604
+ minutes,
605
+ suffix
606
+ } = _ref14;
607
+
608
+ if (days > 7) {
609
+ return 'DD-MM-YYYY';
610
+ }
611
+
612
+ return '[less 7] DD-MM-YYYY';
613
+ },
614
+ ago: "ago",
615
+ later: "later"
616
+ })));
617
+ let tree = ele.toJSON();
440
618
  expect(tree).toMatchSnapshot();
441
619
  });
442
- it('Should display other later- less time', function () {
443
- var ele = renderer.create(React.createElement(
444
- I18NProvider,
445
- { i18n: { today: 'today', yesterday: 'yesterday' } },
446
- React.createElement(DateTimeDiffFormat, {
447
- from: '2016-10-25T05:55:28.000Z',
448
- fromTzData: fromTzData,
449
- to: '2016-10-27T04:55:28.000Z',
450
- toTzData: toTzData,
451
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
452
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
453
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
454
- others: function others(_ref15) {
455
- var years = _ref15.years,
456
- days = _ref15.days,
457
- hours = _ref15.hours,
458
- minutes = _ref15.minutes,
459
- suffix = _ref15.suffix;
460
-
461
- if (days > 7) {
462
- return 'DD-MM-YYYY';
463
- }
464
- return '[less 7] DD-MM-YYYY';
465
- },
466
- ago: 'ago',
467
- later: 'later'
468
- })
469
- ));
470
- var tree = ele.toJSON();
620
+ it('Should display other later- less time', () => {
621
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
622
+ i18n: {
623
+ today: 'today',
624
+ yesterday: 'yesterday'
625
+ }
626
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
627
+ from: "2016-10-25T05:55:28.000Z",
628
+ fromTzData: fromTzData,
629
+ to: "2016-10-27T04:55:28.000Z",
630
+ toTzData: toTzData,
631
+ today: {
632
+ key: 'today',
633
+ params: ['hh', 'mm', 'ss']
634
+ },
635
+ yesterday: {
636
+ key: 'yesterday',
637
+ params: ['hh', 'mm', 'ss']
638
+ },
639
+ tomorrow: {
640
+ key: 'tomorrow',
641
+ params: ['hh', 'mm', 'ss']
642
+ },
643
+ others: _ref15 => {
644
+ let {
645
+ years,
646
+ days,
647
+ hours,
648
+ minutes,
649
+ suffix
650
+ } = _ref15;
651
+
652
+ if (days > 7) {
653
+ return 'DD-MM-YYYY';
654
+ }
655
+
656
+ return '[less 7] DD-MM-YYYY';
657
+ },
658
+ ago: "ago",
659
+ later: "later"
660
+ })));
661
+ let tree = ele.toJSON();
471
662
  expect(tree).toMatchSnapshot();
472
663
  });
473
- it('Should display others', function () {
474
- var ele = renderer.create(React.createElement(
475
- I18NProvider,
476
- { i18n: { today: 'today', yesterday: 'yesterday' } },
477
- React.createElement(DateTimeDiffFormat, {
478
- from: '2016-10-25T05:55:28.000Z',
479
- fromTzData: fromTzData,
480
- to: '2016-11-27T05:55:28.000Z',
481
- toTzData: toTzData,
482
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
483
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
484
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
485
- others: function others(_ref16) {
486
- var years = _ref16.years,
487
- days = _ref16.days,
488
- hours = _ref16.hours,
489
- minutes = _ref16.minutes,
490
- suffix = _ref16.suffix,
491
- isWithInAWeek = _ref16.isWithInAWeek;
492
-
493
- if (days > 7) {
494
- return 'DD-MM-YYYY';
495
- }
496
- return '[less 7] DD-MM-YYYY';
497
- },
498
- ago: 'ago',
499
- later: 'later'
500
- })
501
- ));
502
- var tree = ele.toJSON();
664
+ it('Should display others', () => {
665
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
666
+ i18n: {
667
+ today: 'today',
668
+ yesterday: 'yesterday'
669
+ }
670
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
671
+ from: "2016-10-25T05:55:28.000Z",
672
+ fromTzData: fromTzData,
673
+ to: "2016-11-27T05:55:28.000Z",
674
+ toTzData: toTzData,
675
+ today: {
676
+ key: 'today',
677
+ params: ['hh', 'mm', 'ss']
678
+ },
679
+ yesterday: {
680
+ key: 'yesterday',
681
+ params: ['hh', 'mm', 'ss']
682
+ },
683
+ tomorrow: {
684
+ key: 'tomorrow',
685
+ params: ['hh', 'mm', 'ss']
686
+ },
687
+ others: _ref16 => {
688
+ let {
689
+ years,
690
+ days,
691
+ hours,
692
+ minutes,
693
+ suffix,
694
+ isWithInAWeek
695
+ } = _ref16;
696
+
697
+ if (days > 7) {
698
+ return 'DD-MM-YYYY';
699
+ }
700
+
701
+ return '[less 7] DD-MM-YYYY';
702
+ },
703
+ ago: "ago",
704
+ later: "later"
705
+ })));
706
+ let tree = ele.toJSON();
503
707
  expect(tree).toMatchSnapshot();
504
708
  });
709
+ it('Should display today1', () => {
710
+ 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'];
711
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
712
+ i18n: {
713
+ today: 'today',
714
+ yesterday: 'yesterday',
715
+ now: 'noooow',
716
+ 'support.1day.ago': '1day ago',
717
+ 'support.1day.nhours.ago': 'one day {0} hours ago',
718
+ 'support.1min.ago': '1min ago',
719
+ 'support.nmins.ago': '{0} mins ago'
720
+ }
721
+ }, /*#__PURE__*/React.createElement("div", null, toDates.map((to, i) => /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
722
+ key: i,
723
+ from: "2016-10-25T05:55:28.000Z",
724
+ fromTzData: fromTzData,
725
+ to: to,
726
+ toTzData: toTzData,
727
+ format: (_ref17, pattern) => {
728
+ let {
729
+ years,
730
+ days,
731
+ months,
732
+ hours
733
+ } = _ref17;
734
+
735
+ switch (pattern) {
736
+ case '000000':
737
+ case '000001':
738
+ case '000002':
739
+ return {
740
+ key: 'now'
741
+ };
742
+ break;
743
+
744
+ case '000010':
745
+ return {
746
+ key: 'support.1min'
747
+ };
748
+ break;
749
+
750
+ case '000020':
751
+ return {
752
+ key: 'support.nmins',
753
+ params: ['m']
754
+ };
755
+ break;
505
756
 
506
- it('Should display today1', function () {
507
- var 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'];
508
- var ele = renderer.create(React.createElement(
509
- I18NProvider,
510
- {
511
- i18n: {
512
- today: 'today',
513
- yesterday: 'yesterday',
514
- now: 'noooow',
515
- 'support.1day.ago': '1day ago',
516
- 'support.1day.nhours.ago': 'one day {0} hours ago',
517
- 'support.1min.ago': '1min ago',
518
- 'support.nmins.ago': '{0} mins ago'
757
+ case '001000':
758
+ case '001100':
759
+ return {
760
+ key: 'support.1day'
761
+ };
762
+ break;
763
+
764
+ case '001200':
765
+ case '001201':
766
+ return {
767
+ key: 'support.1day.nhours',
768
+ params: ['h']
769
+ };
770
+ break;
519
771
  }
520
772
  },
521
- React.createElement(
522
- 'div',
523
- null,
524
- toDates.map(function (to, i) {
525
- return React.createElement(DateTimeDiffFormat, {
526
- key: i,
527
- from: '2016-10-25T05:55:28.000Z',
528
- fromTzData: fromTzData,
529
- to: to,
530
- toTzData: toTzData,
531
- format: function format(_ref17, pattern) {
532
- var years = _ref17.years,
533
- days = _ref17.days,
534
- months = _ref17.months,
535
- hours = _ref17.hours;
536
-
537
- switch (pattern) {
538
- case '000000':
539
- case '000001':
540
- case '000002':
541
- return {
542
- key: 'now'
543
- };
544
- break;
545
- case '000010':
546
- return {
547
- key: 'support.1min'
548
- };
549
- break;
550
- case '000020':
551
- return {
552
- key: 'support.nmins',
553
- params: ['m']
554
- };
555
- break;
556
- case '001000':
557
- case '001100':
558
- return {
559
- key: 'support.1day'
560
- };
561
- break;
562
- case '001200':
563
- case '001201':
564
- return {
565
- key: 'support.1day.nhours',
566
- params: ['h']
567
- };
568
- break;
569
- }
570
- },
571
- ago: 'ago',
572
- later: 'later'
573
- });
574
- })
575
- )
576
- ));
577
- var tree = ele.toJSON();
773
+ ago: "ago",
774
+ later: "later"
775
+ })))));
776
+ let tree = ele.toJSON();
578
777
  expect(tree).toMatchSnapshot();
579
778
  });
580
- it('Should display today later', function () {
581
- var ele = renderer.create(React.createElement(
582
- I18NProvider,
583
- {
584
- i18n: {
585
- today: 'today',
586
- yesterday: 'yesterday',
587
- 'today.later': '{0}:{1}:{2} later'
779
+ it('Should display today later', () => {
780
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
781
+ i18n: {
782
+ today: 'today',
783
+ yesterday: 'yesterday',
784
+ 'today.later': '{0}:{1}:{2} later'
785
+ }
786
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
787
+ from: "2016-10-25T05:55:28.000Z",
788
+ fromTzData: fromTzData,
789
+ to: "2016-10-25T05:55:29.000Z",
790
+ toTzData: toTzData,
791
+ today: {
792
+ key: 'today',
793
+ params: ['hh', 'mm', 'ss']
794
+ },
795
+ yesterday: {
796
+ key: 'yesterday',
797
+ params: ['hh', 'mm', 'ss']
798
+ },
799
+ tomorrow: {
800
+ key: 'tomorrow',
801
+ params: ['hh', 'mm', 'ss']
802
+ },
803
+ others: _ref18 => {
804
+ let {
805
+ years,
806
+ days,
807
+ hours,
808
+ minutes
809
+ } = _ref18;
810
+
811
+ if (days > 7) {
812
+ return 'DD-MM-YYYY';
588
813
  }
814
+
815
+ return getDateKeyWithParam(years, days, hours, minutes);
589
816
  },
590
- React.createElement(DateTimeDiffFormat, {
591
- from: '2016-10-25T05:55:28.000Z',
592
- fromTzData: fromTzData,
593
- to: '2016-10-25T05:55:29.000Z',
594
- toTzData: toTzData,
595
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
596
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
597
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
598
- others: function others(_ref18) {
599
- var years = _ref18.years,
600
- days = _ref18.days,
601
- hours = _ref18.hours,
602
- minutes = _ref18.minutes;
603
-
604
- if (days > 7) {
605
- return 'DD-MM-YYYY';
606
- }
607
- return getDateKeyWithParam(years, days, hours, minutes);
608
- },
609
- ago: 'ago',
610
- later: 'later'
611
- })
612
- ));
613
- var tree = ele.toJSON();
817
+ ago: "ago",
818
+ later: "later"
819
+ })));
820
+ let tree = ele.toJSON();
614
821
  expect(tree).toMatchSnapshot();
615
822
  });
616
- it('Should display today ago', function () {
617
- var ele = renderer.create(React.createElement(
618
- I18NProvider,
619
- {
620
- i18n: {
621
- today: 'today',
622
- yesterday: 'yesterday',
623
- 'today.later': '{0}:{1}:{2} later',
624
- 'today.ago': '{0}:{1}:{2} ago'
823
+ it('Should display today ago', () => {
824
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
825
+ i18n: {
826
+ today: 'today',
827
+ yesterday: 'yesterday',
828
+ 'today.later': '{0}:{1}:{2} later',
829
+ 'today.ago': '{0}:{1}:{2} ago'
830
+ }
831
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
832
+ from: "2016-10-25T05:55:30.000Z",
833
+ fromTzData: fromTzData,
834
+ to: "2016-10-25T05:55:29.000Z",
835
+ toTzData: toTzData,
836
+ today: {
837
+ key: 'today',
838
+ params: ['hh', 'mm', 'ss']
839
+ },
840
+ yesterday: {
841
+ key: 'yesterday',
842
+ params: ['hh', 'mm', 'ss']
843
+ },
844
+ tomorrow: {
845
+ key: 'tomorrow',
846
+ params: ['hh', 'mm', 'ss']
847
+ },
848
+ others: _ref19 => {
849
+ let {
850
+ years,
851
+ days,
852
+ hours,
853
+ minutes
854
+ } = _ref19;
855
+
856
+ if (days > 7) {
857
+ return 'DD-MM-YYYY';
625
858
  }
859
+
860
+ return getDateKeyWithParam(years, days, hours, minutes);
626
861
  },
627
- React.createElement(DateTimeDiffFormat, {
628
- from: '2016-10-25T05:55:30.000Z',
629
- fromTzData: fromTzData,
630
- to: '2016-10-25T05:55:29.000Z',
631
- toTzData: toTzData,
632
- today: { key: 'today', params: ['hh', 'mm', 'ss'] },
633
- yesterday: { key: 'yesterday', params: ['hh', 'mm', 'ss'] },
634
- tomorrow: { key: 'tomorrow', params: ['hh', 'mm', 'ss'] },
635
- others: function others(_ref19) {
636
- var years = _ref19.years,
637
- days = _ref19.days,
638
- hours = _ref19.hours,
639
- minutes = _ref19.minutes;
640
-
641
- if (days > 7) {
642
- return 'DD-MM-YYYY';
643
- }
644
- return getDateKeyWithParam(years, days, hours, minutes);
645
- },
646
- ago: 'ago',
647
- later: 'later'
648
- })
649
- ));
650
- var tree = ele.toJSON();
862
+ ago: "ago",
863
+ later: "later"
864
+ })));
865
+ let tree = ele.toJSON();
651
866
  expect(tree).toMatchSnapshot();
652
867
  });
653
- it('Should display years and days', function () {
654
- var ele = renderer.create(React.createElement(
655
- I18NProvider,
656
- {
657
- i18n: {
658
- 'nyear.ndays.ago': '{0} years {1} days ago',
659
- yesterday: 'yesterday'
868
+ it('Should display years and days', () => {
869
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
870
+ i18n: {
871
+ 'nyear.ndays.ago': '{0} years {1} days ago',
872
+ yesterday: 'yesterday'
873
+ }
874
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
875
+ from: "2017-10-25T05:55:28.000Z",
876
+ fromTzData: fromTzData,
877
+ to: "2015-08-25T05:55:28.000Z",
878
+ toTzData: toTzData,
879
+ format: (_ref20, pattern) => {
880
+ let {
881
+ years,
882
+ days,
883
+ months,
884
+ hours
885
+ } = _ref20;
886
+
887
+ if (years > 1) {
888
+ return {
889
+ key: 'nyear.ndays',
890
+ params: ['y', 'days']
891
+ };
660
892
  }
661
893
  },
662
- React.createElement(DateTimeDiffFormat, {
663
- from: '2017-10-25T05:55:28.000Z',
664
- fromTzData: fromTzData,
665
- to: '2015-08-25T05:55:28.000Z',
666
- toTzData: toTzData,
667
- format: function format(_ref20, pattern) {
668
- var years = _ref20.years,
669
- days = _ref20.days,
670
- months = _ref20.months,
671
- hours = _ref20.hours;
672
-
673
- if (years > 1) {
674
- return {
675
- key: 'nyear.ndays',
676
- params: ['y', 'days']
677
- };
678
- }
679
- },
680
- ago: 'ago',
681
- later: 'later'
682
- })
683
- ));
684
- var tree = ele.toJSON();
894
+ ago: "ago",
895
+ later: "later"
896
+ })));
897
+ let tree = ele.toJSON();
685
898
  expect(tree).toMatchSnapshot();
686
899
  });
687
- it('Should display years and days1', function () {
688
- var ele = renderer.create(React.createElement(
689
- I18NProvider,
690
- {
691
- i18n: {
692
- 'nyear.ndays.later': '{0} years {1} days later',
693
- yesterday: 'yesterday'
900
+ it('Should display years and days1', () => {
901
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
902
+ i18n: {
903
+ 'nyear.ndays.later': '{0} years {1} days later',
904
+ yesterday: 'yesterday'
905
+ }
906
+ }, /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
907
+ from: "2015-08-25T05:55:28.000Z",
908
+ fromTzData: fromTzData,
909
+ to: "2017-10-25T05:55:28.000Z",
910
+ toTzData: toTzData,
911
+ format: (_ref21, pattern) => {
912
+ let {
913
+ years,
914
+ days,
915
+ months,
916
+ hours
917
+ } = _ref21;
918
+
919
+ if (years > 1) {
920
+ return {
921
+ key: 'nyear.ndays',
922
+ params: ['y', 'days']
923
+ };
694
924
  }
695
925
  },
696
- React.createElement(DateTimeDiffFormat, {
697
- from: '2015-08-25T05:55:28.000Z',
698
- fromTzData: fromTzData,
699
- to: '2017-10-25T05:55:28.000Z',
700
- toTzData: toTzData,
701
- format: function format(_ref21, pattern) {
702
- var years = _ref21.years,
703
- days = _ref21.days,
704
- months = _ref21.months,
705
- hours = _ref21.hours;
706
-
707
- if (years > 1) {
708
- return {
709
- key: 'nyear.ndays',
710
- params: ['y', 'days']
711
- };
712
- }
713
- },
714
- ago: 'ago',
715
- later: 'later'
716
- })
717
- ));
718
- var tree = ele.toJSON();
926
+ ago: "ago",
927
+ later: "later"
928
+ })));
929
+ let tree = ele.toJSON();
719
930
  expect(tree).toMatchSnapshot();
720
931
  });
721
932
  });