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