handlebars-i18n 1.7.1 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/handlebars-i18n.js +66 -1
- package/dist/handlebars-i18n.min.js +1 -1
- package/examples/browser-example/index.html +17 -9
- package/examples/node-example/simple-example.js +87 -71
- package/examples/typescript/test.hbs +13 -7
- package/package.json +1 -1
- package/readme.md +49 -50
- package/test/handlebars-i18n.test.js +236 -81
|
@@ -59,6 +59,10 @@ describe('handlebars-i18n Tests', function () {
|
|
|
59
59
|
assert.isFunction(hI18n.helpers._date);
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
+
it('after method call init() HandlebarsEnvironment object should have a function _dateAdd', function () {
|
|
63
|
+
assert.isFunction(hI18n.helpers._dateAdd);
|
|
64
|
+
});
|
|
65
|
+
|
|
62
66
|
it('after method call init() HandlebarsEnvironment object should have a function _dateRel', function () {
|
|
63
67
|
assert.isFunction(hI18n.helpers._dateRel);
|
|
64
68
|
});
|
|
@@ -99,19 +103,19 @@ describe('handlebars-i18n Tests', function () {
|
|
|
99
103
|
Tests against function _locale
|
|
100
104
|
****************************************/
|
|
101
105
|
|
|
102
|
-
it('expecting
|
|
106
|
+
it('expecting _locale to be [undefined] as long as no language was set with i18next.init', function () {
|
|
103
107
|
i18next.init(); // empty init
|
|
104
108
|
const res = hI18n.helpers._locale();
|
|
105
109
|
expect(res).to.be.undefined;
|
|
106
110
|
});
|
|
107
111
|
|
|
108
|
-
it('
|
|
112
|
+
it('_locale should return "en" if language is specified as "en" by init Object', function () {
|
|
109
113
|
i18next.init(i18nInitObj); // initialize with data
|
|
110
114
|
const res = hI18n.helpers._locale();
|
|
111
115
|
assert.equal('en', res);
|
|
112
116
|
});
|
|
113
117
|
|
|
114
|
-
it('
|
|
118
|
+
it('_locale should return "de" after language change to "de"', function () {
|
|
115
119
|
i18next.changeLanguage('de');
|
|
116
120
|
const res = hI18n.helpers._locale();
|
|
117
121
|
assert.equal('de', res);
|
|
@@ -145,29 +149,29 @@ describe('handlebars-i18n Tests', function () {
|
|
|
145
149
|
}).to.throw();
|
|
146
150
|
});
|
|
147
151
|
|
|
148
|
-
it('
|
|
152
|
+
it('__ should return a SafeString object with property "string" where "string" returns the first argument given to __', function () {
|
|
149
153
|
const res = hI18n.helpers.__("someNoneExitingKey", {hash: {}});
|
|
150
154
|
assert.equal("someNoneExitingKey", res.string);
|
|
151
155
|
});
|
|
152
156
|
|
|
153
|
-
it('
|
|
157
|
+
it('__ should return a SafeString object with property "string" where "string" contains "What is good?!', function () {
|
|
154
158
|
const res = hI18n.helpers.__("key1", {hash: {}});
|
|
155
159
|
assert.equal("What is good?", res.string);
|
|
156
160
|
});
|
|
157
161
|
|
|
158
|
-
it('
|
|
162
|
+
it('__ should return a SafeString object with property "string" where "string" contains "Was ist gut?"', function () {
|
|
159
163
|
i18next.changeLanguage('de');
|
|
160
164
|
const res = hI18n.helpers.__("key1", {hash: {}});
|
|
161
165
|
assert.equal("Was ist gut?", res.string);
|
|
162
166
|
});
|
|
163
167
|
|
|
164
|
-
it('
|
|
168
|
+
it('__ should return a SafeString object with property "string" where "string" contains "handlebarsI18next is good."', function () {
|
|
165
169
|
i18next.changeLanguage('en');
|
|
166
170
|
const res = hI18n.helpers.__("key2", {hash: {what: "handlebarsI18next", adverb: "good"}});
|
|
167
171
|
assert.equal("handlebarsI18next is good.", res.string);
|
|
168
172
|
});
|
|
169
173
|
|
|
170
|
-
it('
|
|
174
|
+
it('__ should return a SafeString object with property "string" where "string" contains "handlebarsI18next ist gut."', function () {
|
|
171
175
|
i18next.changeLanguage('de');
|
|
172
176
|
const res = hI18n.helpers.__("key2", {hash: {what: "handlebarsI18next", adverb: "gut"}});
|
|
173
177
|
assert.equal("handlebarsI18next ist gut.", res.string);
|
|
@@ -178,13 +182,13 @@ describe('handlebars-i18n Tests', function () {
|
|
|
178
182
|
Tests against function _date
|
|
179
183
|
****************************************/
|
|
180
184
|
|
|
181
|
-
it('expect
|
|
185
|
+
it('expect _date to throw error when called with invalid date parameter', function () {
|
|
182
186
|
expect(function () {
|
|
183
187
|
hI18n.helpers._date('someStrangeString')
|
|
184
188
|
}).to.throw("Invalid valid date passed to format");
|
|
185
189
|
});
|
|
186
190
|
|
|
187
|
-
it('
|
|
191
|
+
it('_date should return today’s date in Intl default format when called without parameter', function () {
|
|
188
192
|
i18next.changeLanguage('en');
|
|
189
193
|
const today = new Date();
|
|
190
194
|
const todayFormated = new Intl.DateTimeFormat().format(today);
|
|
@@ -193,7 +197,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
193
197
|
assert.equal(todayFormated, res);
|
|
194
198
|
});
|
|
195
199
|
|
|
196
|
-
it('
|
|
200
|
+
it('_date should return today’s date in Intl default format when called with parameter, "Today" or "Now" no matter of upper or lower case writing',
|
|
197
201
|
function () {
|
|
198
202
|
i18next.changeLanguage('en');
|
|
199
203
|
const today = new Date();
|
|
@@ -207,91 +211,242 @@ describe('handlebars-i18n Tests', function () {
|
|
|
207
211
|
assert.equal(todayFormated, hI18n.helpers._date("NOW"));
|
|
208
212
|
});
|
|
209
213
|
|
|
210
|
-
it('
|
|
214
|
+
it('_date should return "1/1/1970" (Intl default format) when called with parameter 1 as number ', function () {
|
|
211
215
|
i18next.changeLanguage('en');
|
|
212
216
|
const res = hI18n.helpers._date(1);
|
|
213
217
|
assert.equal('1/1/1970', res);
|
|
214
218
|
});
|
|
215
219
|
|
|
216
|
-
it('
|
|
220
|
+
it('_date should return "12/17/1995" (Intl default format) when called with parameter "1995-12-17T03:24:00"', function () {
|
|
217
221
|
i18next.changeLanguage('en');
|
|
218
222
|
const res = hI18n.helpers._date('1995-12-17T03:24:00');
|
|
219
223
|
assert.equal('12/17/1995', res);
|
|
220
224
|
});
|
|
221
225
|
|
|
222
|
-
it('
|
|
226
|
+
it('_date should return "12/17/1995" (Intl default format) when called with parameter "December 17, 1995 03:24:00"', function () {
|
|
223
227
|
i18next.changeLanguage('en');
|
|
224
228
|
const res = hI18n.helpers._date('December 17, 1995 03:24:00');
|
|
225
229
|
assert.equal('12/17/1995', res);
|
|
226
230
|
});
|
|
227
231
|
|
|
228
|
-
it('
|
|
232
|
+
it('_date should return "1/1/2020" (Intl default format) when called with parameter "[2020]"', function () {
|
|
229
233
|
i18next.changeLanguage('en');
|
|
230
234
|
const res = hI18n.helpers._date('[1995]');
|
|
231
235
|
assert.equal('1/1/1995', res);
|
|
232
236
|
});
|
|
233
237
|
|
|
234
|
-
it('
|
|
238
|
+
it('_date should return "12/1/1995" (Intl default format) when called with parameter "[2020,11]"', function () {
|
|
235
239
|
i18next.changeLanguage('en');
|
|
236
240
|
const res = hI18n.helpers._date('[1995,11]');
|
|
237
241
|
assert.equal('12/1/1995', res);
|
|
238
242
|
});
|
|
239
243
|
|
|
240
|
-
it('
|
|
244
|
+
it('_date should return "12/17/1995" (Intl default format) when called with parameter "[2020,11,17]"', function () {
|
|
241
245
|
i18next.changeLanguage('en');
|
|
242
246
|
const res = hI18n.helpers._date('[1995,11,17]');
|
|
243
247
|
assert.equal('12/17/1995', res);
|
|
244
248
|
});
|
|
245
249
|
|
|
246
|
-
it('
|
|
250
|
+
it('_date should return "12/1/95" when called with parameter "[2020,11,01] and specifying options"', function () {
|
|
247
251
|
i18next.changeLanguage('en');
|
|
248
252
|
const res = hI18n.helpers._date('[1995,11,1]', {hash: {year: "2-digit", month: "2-digit", day: "2-digit"}});
|
|
249
253
|
assert.equal('12/1/95', res);
|
|
250
254
|
});
|
|
251
255
|
|
|
252
|
-
it('
|
|
256
|
+
it('_date should return "01.12.95" when called with parameter "[2020,11,01] and specifying options an language set to "de"', function () {
|
|
253
257
|
i18next.changeLanguage('de');
|
|
254
258
|
const res = hI18n.helpers._date('[1995,11,1]', {hash: {year: "2-digit", month: "2-digit", day: "2-digit"}});
|
|
255
259
|
assert.equal('01.12.95', res);
|
|
256
260
|
});
|
|
257
261
|
|
|
258
262
|
|
|
263
|
+
/****************************************
|
|
264
|
+
Tests against function _dateAdd
|
|
265
|
+
****************************************/
|
|
266
|
+
|
|
267
|
+
it('_dateAdd should throw error when called without params', function () {
|
|
268
|
+
expect(function () {
|
|
269
|
+
hI18n.helpers._dateAdd()
|
|
270
|
+
}).to.throw("@ handlebars-i18n: invalid first argument \"dateInput\" was given for _dateAdd.");
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it('_dateAdd should throw error when called without 2nd param', function () {
|
|
274
|
+
expect(function () {
|
|
275
|
+
hI18n.helpers._dateAdd('December 17, 1995 02:00:00')
|
|
276
|
+
}).to.throw("@ handlebars-i18n: invalid second argument \"offset\" was given for _dateAdd.");
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('_dateAdd should use default unit "hour" when called without 3rd param', function () {
|
|
280
|
+
i18next.changeLanguage('en');
|
|
281
|
+
const res = hI18n.helpers._dateAdd('December 17, 1995 02:00:00', 25);
|
|
282
|
+
assert.equal('12/18/1995', res);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it('_dateAdd should return "12/17/1995" when called with parameters "December 17, 1995 02:00:00", 1, and "day"', function () {
|
|
286
|
+
i18next.changeLanguage('en');
|
|
287
|
+
const res = hI18n.helpers._dateAdd('December 17, 1995 02:00:00', 1, {"hash": {unit: "day"}});
|
|
288
|
+
assert.equal('12/18/1995', res);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
// -- Test for "second" -- //
|
|
292
|
+
|
|
293
|
+
it('_dateAdd should return "12/18/1995" when called with parameters "December 17, 1995 02:00:00", 1, and "second"', function () {
|
|
294
|
+
i18next.changeLanguage('en');
|
|
295
|
+
const options = {hash: {unit: "second", hour: "2-digit", minute: "2-digit", second: "2-digit"}}
|
|
296
|
+
const res = hI18n.helpers._dateAdd('December 17, 1995 02:00:00', 1, options);
|
|
297
|
+
assert.equal('02:00:01', res);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
// -- Test for "minute" -- //
|
|
301
|
+
|
|
302
|
+
it('_dateAdd should return "02:01:00" when called with parameters "December 17, 1995 02:00:00", 1, and "minute"', function () {
|
|
303
|
+
i18next.changeLanguage('en');
|
|
304
|
+
const options = {hash: {unit: "minute", hour: "2-digit", minute: "2-digit", second: "2-digit"}}
|
|
305
|
+
const res = hI18n.helpers._dateAdd('December 17, 1995 02:00:00', 1, options);
|
|
306
|
+
assert.equal('02:01:00', res);
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
// -- Test for "hour" -- //
|
|
310
|
+
|
|
311
|
+
it('_dateAdd should return "03:00:00" when called with parameters "December 17, 1995 02:00:00", 1, and "hour"', function () {
|
|
312
|
+
i18next.changeLanguage('en');
|
|
313
|
+
const options = {hash: {unit: "hour", hour: "2-digit", minute: "2-digit", second: "2-digit"}}
|
|
314
|
+
const res = hI18n.helpers._dateAdd('December 17, 1995 02:00:00', 1, options);
|
|
315
|
+
assert.equal('03:00:00', res);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
// -- Test for "day" -- //
|
|
319
|
+
|
|
320
|
+
it('_dateAdd should return "December 18, 1995 02:00:00" when called with parameters "December 17, 1995 02:00:00", 1, and "day"', function () {
|
|
321
|
+
i18next.changeLanguage('en');
|
|
322
|
+
const options = {
|
|
323
|
+
hash: {
|
|
324
|
+
unit: "day",
|
|
325
|
+
year: "numeric",
|
|
326
|
+
month: "long",
|
|
327
|
+
day: "2-digit",
|
|
328
|
+
hour: "2-digit",
|
|
329
|
+
minute: "2-digit",
|
|
330
|
+
second: "2-digit"
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
const res = hI18n.helpers._dateAdd('December 17, 1995 02:00:00', 1, options);
|
|
334
|
+
assert.equal('December 18, 1995 at 02:00:00', res);
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
// -- Test for "week" -- //
|
|
338
|
+
|
|
339
|
+
it('_dateAdd should return "December 24, 1995 02:00:00" when called with parameters "December 17, 1995 02:00:00", 1, and "week"', function () {
|
|
340
|
+
i18next.changeLanguage('en');
|
|
341
|
+
const options = {
|
|
342
|
+
hash: {
|
|
343
|
+
unit: "week",
|
|
344
|
+
year: "numeric",
|
|
345
|
+
month: "long",
|
|
346
|
+
day: "2-digit",
|
|
347
|
+
hour: "2-digit",
|
|
348
|
+
minute: "2-digit",
|
|
349
|
+
second: "2-digit"
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
const res = hI18n.helpers._dateAdd('December 17, 1995 02:00:00', 1, options);
|
|
353
|
+
assert.equal('December 24, 1995 at 02:00:00', res);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
// -- Test for "month" -- //
|
|
357
|
+
|
|
358
|
+
it('_dateAdd should return "January 17, 1996 02:00:00" when called with parameters "December 17, 1995 02:00:00", 1, and "month"', function () {
|
|
359
|
+
i18next.changeLanguage('en');
|
|
360
|
+
const options = {
|
|
361
|
+
hash: {
|
|
362
|
+
unit: "month",
|
|
363
|
+
year: "numeric",
|
|
364
|
+
month: "long",
|
|
365
|
+
day: "2-digit",
|
|
366
|
+
hour: "2-digit",
|
|
367
|
+
minute: "2-digit",
|
|
368
|
+
second: "2-digit"
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
const res = hI18n.helpers._dateAdd('December 17, 1995 02:00:00', 1, options);
|
|
372
|
+
assert.equal('January 17, 1996 at 02:00:00', res);
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
// -- Test for "quarter" -- //
|
|
376
|
+
|
|
377
|
+
it('_dateAdd should return "March 17, 1996 02:00:00" when called with parameters "December 17, 1995 02:00:00", 1, and "quarter"', function () {
|
|
378
|
+
i18next.changeLanguage('en');
|
|
379
|
+
const options = {
|
|
380
|
+
hash: {
|
|
381
|
+
unit: "quarter",
|
|
382
|
+
year: "numeric",
|
|
383
|
+
month: "long",
|
|
384
|
+
day: "2-digit",
|
|
385
|
+
hour: "2-digit",
|
|
386
|
+
minute: "2-digit",
|
|
387
|
+
second: "2-digit"
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
const res = hI18n.helpers._dateAdd('December 17, 1995 02:00:00', 1, options);
|
|
391
|
+
assert.equal('March 17, 1996 at 02:00:00', res);
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
// -- Test for "year" -- //
|
|
395
|
+
|
|
396
|
+
it('_dateAdd should return "December 17, 1996 02:00:00" when called with parameters "December 17, 1995 02:00:00", 1, and "year"', function () {
|
|
397
|
+
i18next.changeLanguage('en');
|
|
398
|
+
const options = {
|
|
399
|
+
hash: {
|
|
400
|
+
unit: "year",
|
|
401
|
+
year: "numeric",
|
|
402
|
+
month: "long",
|
|
403
|
+
day: "2-digit",
|
|
404
|
+
hour: "2-digit",
|
|
405
|
+
minute: "2-digit",
|
|
406
|
+
second: "2-digit"
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
const res = hI18n.helpers._dateAdd('December 17, 1995 02:00:00', 1, options);
|
|
410
|
+
assert.equal('December 17, 1996 at 02:00:00', res);
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
|
|
259
414
|
/****************************************
|
|
260
415
|
Tests against function _dateRel
|
|
261
416
|
****************************************/
|
|
262
417
|
|
|
263
|
-
it('expect
|
|
418
|
+
it('expect _dateRel to throw error when called without parameter', function () {
|
|
264
419
|
expect(function () {
|
|
265
420
|
hI18n.helpers._dateRel()
|
|
266
421
|
}).to.throw('Invalid "number" argument: NaN');
|
|
267
422
|
});
|
|
268
423
|
|
|
269
|
-
it('expect
|
|
424
|
+
it('expect _dateRel to throw error when called with invalid date parameter', function () {
|
|
270
425
|
expect(function () {
|
|
271
426
|
hI18n.helpers._dateRel('someStrangeString')
|
|
272
427
|
}).to.throw('Invalid "number" argument: NaN');
|
|
273
428
|
});
|
|
274
429
|
|
|
275
|
-
it('expect
|
|
430
|
+
it('expect _dateRel to throw error when called with non-existent language shortcode', function () {
|
|
276
431
|
i18next.changeLanguage('invalid');
|
|
277
432
|
expect(function () {
|
|
278
433
|
hI18n.helpers._dateRel(1, {hash: {localeMatcher: "best fit", numeric: "always", style: "long", unit: "day"}})
|
|
279
434
|
}).to.throw('No locale data passed');
|
|
280
435
|
});
|
|
281
436
|
|
|
282
|
-
it('expect
|
|
437
|
+
it('expect _dateRel to return \'in 1 hour\' when called with \'en\' and first parameter being 1', function () {
|
|
283
438
|
i18next.changeLanguage('en');
|
|
284
439
|
const res = hI18n.helpers._dateRel(1);
|
|
285
440
|
assert.equal('in 1 hour', res);
|
|
286
441
|
});
|
|
287
442
|
|
|
288
|
-
it('expect
|
|
443
|
+
it('expect _dateRel to return \'1 hour ago\' when called with \'en\' and first parameter being -1', function () {
|
|
289
444
|
i18next.changeLanguage('en');
|
|
290
445
|
const res = hI18n.helpers._dateRel(-1);
|
|
291
446
|
assert.equal('1 hour ago', res);
|
|
292
447
|
});
|
|
293
448
|
|
|
294
|
-
it('expect
|
|
449
|
+
it('expect _dateRel to return \'in 1 second\' when called with \'en\' and first parameter being 1 and according options', function () {
|
|
295
450
|
i18next.changeLanguage('en');
|
|
296
451
|
const res = hI18n.helpers._dateRel(1, {
|
|
297
452
|
hash: {
|
|
@@ -304,7 +459,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
304
459
|
assert.equal('in 1 second', res);
|
|
305
460
|
});
|
|
306
461
|
|
|
307
|
-
it('expect
|
|
462
|
+
it('expect _dateRel to return \'in 1 Tag\' when called with \'de\' and paramter 1 and according options', function () {
|
|
308
463
|
i18next.changeLanguage('de');
|
|
309
464
|
const res = hI18n.helpers._dateRel(1, {
|
|
310
465
|
hash: {
|
|
@@ -322,33 +477,33 @@ describe('handlebars-i18n Tests', function () {
|
|
|
322
477
|
Tests against function _dateDiff
|
|
323
478
|
****************************************/
|
|
324
479
|
|
|
325
|
-
it('
|
|
480
|
+
it('_dateDiff should return null when called with no parameter', function () {
|
|
326
481
|
i18next.changeLanguage('en');
|
|
327
482
|
const res = hI18n.helpers._dateDiff();
|
|
328
483
|
assert.equal(null, res);
|
|
329
484
|
});
|
|
330
485
|
|
|
331
|
-
it('expect
|
|
486
|
+
it('expect _dateDiff to throw error when called with invalid 1. date parameter', function () {
|
|
332
487
|
expect(function () {
|
|
333
488
|
hI18n.helpers._dateDiff('someStrangeString', '1995-12-17T03:24:00')
|
|
334
489
|
})
|
|
335
490
|
.to.throw('Invalid "number" argument: NaN');
|
|
336
491
|
});
|
|
337
492
|
|
|
338
|
-
it('expect
|
|
493
|
+
it('expect _dateDiff to throw error when called with invalid 2. date parameter', function () {
|
|
339
494
|
expect(function () {
|
|
340
495
|
hI18n.helpers._dateDiff('1995-12-17T03:24:00', 'someStrangeString')
|
|
341
496
|
})
|
|
342
497
|
.to.throw('Invalid "number" argument: NaN');
|
|
343
498
|
});
|
|
344
499
|
|
|
345
|
-
it('expect
|
|
500
|
+
it('expect _dateDiff to return null when called with empty argument', function () {
|
|
346
501
|
i18next.changeLanguage('en');
|
|
347
502
|
const res = hI18n.helpers._dateDiff('');
|
|
348
503
|
assert.equal(null, res);
|
|
349
504
|
});
|
|
350
505
|
|
|
351
|
-
it('expect
|
|
506
|
+
it('expect _dateDiff to return "in 0 hours", when dates are identical', function () {
|
|
352
507
|
i18next.changeLanguage('en');
|
|
353
508
|
const res = hI18n.helpers._dateDiff('1995-12-17T00:00:00', '1995-12-17T00:00:00');
|
|
354
509
|
assert.equal('in 0 hours', res);
|
|
@@ -356,14 +511,14 @@ describe('handlebars-i18n Tests', function () {
|
|
|
356
511
|
|
|
357
512
|
// -- Test year -- //
|
|
358
513
|
|
|
359
|
-
it('expect
|
|
514
|
+
it('expect _dateDiff to return "in 1 year"', function () {
|
|
360
515
|
i18next.changeLanguage('en');
|
|
361
516
|
const hash = {hash: {localeMatcher: "best fit", numeric: "always", style: "long", unit: "year"}};
|
|
362
517
|
const res = hI18n.helpers._dateDiff('1996-12-17T00:00:00', '1995-12-17T00:00:00', hash);
|
|
363
518
|
assert.equal('in 1 year', res);
|
|
364
519
|
});
|
|
365
520
|
|
|
366
|
-
it('expect
|
|
521
|
+
it('expect _dateDiff to return "1 year ago"', function () {
|
|
367
522
|
i18next.changeLanguage('en');
|
|
368
523
|
const hash = {hash: {localeMatcher: "best fit", numeric: "always", style: "long", unit: "year"}};
|
|
369
524
|
const res = hI18n.helpers._dateDiff('1995-12-17T00:00:00', '1996-12-17T00:00:00', hash);
|
|
@@ -372,7 +527,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
372
527
|
|
|
373
528
|
// -- Test quarter -- //
|
|
374
529
|
|
|
375
|
-
it('expect
|
|
530
|
+
it('expect _dateDiff to return "in 1 quarter"', function () {
|
|
376
531
|
i18next.changeLanguage('en');
|
|
377
532
|
const unit = 'quarter';
|
|
378
533
|
const hash = {hash: {localeMatcher: "best fit", numeric: "always", style: "long", unit: unit}};
|
|
@@ -380,7 +535,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
380
535
|
assert.equal(`in 1 ${unit}`, res);
|
|
381
536
|
});
|
|
382
537
|
|
|
383
|
-
it('expect
|
|
538
|
+
it('expect _dateDiff to return "1 quarter ago"', function () {
|
|
384
539
|
i18next.changeLanguage('en');
|
|
385
540
|
const unit = 'quarter';
|
|
386
541
|
const hash = {hash: {localeMatcher: "best fit", numeric: "always", style: "long", unit: unit}};
|
|
@@ -390,7 +545,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
390
545
|
|
|
391
546
|
// -- Test month -- //
|
|
392
547
|
|
|
393
|
-
it('expect
|
|
548
|
+
it('expect _dateDiff to return "in 1 month"', function () {
|
|
394
549
|
i18next.changeLanguage('en');
|
|
395
550
|
const unit = 'month';
|
|
396
551
|
const hash = {hash: {localeMatcher: "best fit", numeric: "always", style: "long", unit: unit}};
|
|
@@ -398,7 +553,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
398
553
|
assert.equal(`in 1 ${unit}`, res);
|
|
399
554
|
});
|
|
400
555
|
|
|
401
|
-
it('expect
|
|
556
|
+
it('expect _dateDiff to return "1 month ago"', function () {
|
|
402
557
|
i18next.changeLanguage('en');
|
|
403
558
|
const unit = 'month';
|
|
404
559
|
const hash = {hash: {localeMatcher: "best fit", numeric: "always", style: "long", unit: unit}};
|
|
@@ -408,7 +563,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
408
563
|
|
|
409
564
|
// -- Test week -- //
|
|
410
565
|
|
|
411
|
-
it('expect
|
|
566
|
+
it('expect _dateDiff to return "in 1 week"', function () {
|
|
412
567
|
i18next.changeLanguage('en');
|
|
413
568
|
const unit = 'week';
|
|
414
569
|
const hash = {hash: {localeMatcher: "best fit", numeric: "always", style: "long", unit: unit}};
|
|
@@ -416,7 +571,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
416
571
|
assert.equal(`in 1 ${unit}`, res);
|
|
417
572
|
});
|
|
418
573
|
|
|
419
|
-
it('expect
|
|
574
|
+
it('expect _dateDiff to return "1 week ago"', function () {
|
|
420
575
|
i18next.changeLanguage('en');
|
|
421
576
|
const unit = 'week';
|
|
422
577
|
const hash = {hash: {localeMatcher: "best fit", numeric: "always", style: "long", unit: unit}};
|
|
@@ -426,7 +581,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
426
581
|
|
|
427
582
|
// -- Test day -- //
|
|
428
583
|
|
|
429
|
-
it('expect
|
|
584
|
+
it('expect _dateDiff to return "in 1 day"', function () {
|
|
430
585
|
i18next.changeLanguage('en');
|
|
431
586
|
const unit = 'day';
|
|
432
587
|
const hash = {hash: {localeMatcher: "best fit", numeric: "always", style: "long", unit: unit}};
|
|
@@ -434,7 +589,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
434
589
|
assert.equal(`in 1 ${unit}`, res);
|
|
435
590
|
});
|
|
436
591
|
|
|
437
|
-
it('expect
|
|
592
|
+
it('expect _dateDiff to return "1 day ago"', function () {
|
|
438
593
|
i18next.changeLanguage('en');
|
|
439
594
|
const unit = 'day';
|
|
440
595
|
const hash = {hash: {localeMatcher: "best fit", numeric: "always", style: "long", unit: unit}};
|
|
@@ -444,7 +599,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
444
599
|
|
|
445
600
|
// -- Test minute -- //
|
|
446
601
|
|
|
447
|
-
it('expect
|
|
602
|
+
it('expect _dateDiff to return "in 1 minute"', function () {
|
|
448
603
|
i18next.changeLanguage('en');
|
|
449
604
|
const unit = 'minute';
|
|
450
605
|
const hash = {hash: {localeMatcher: "best fit", numeric: "always", style: "long", unit: unit}};
|
|
@@ -452,7 +607,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
452
607
|
assert.equal(`in 1 ${unit}`, res);
|
|
453
608
|
});
|
|
454
609
|
|
|
455
|
-
it('expect
|
|
610
|
+
it('expect _dateDiff to return "1 minute ago"', function () {
|
|
456
611
|
i18next.changeLanguage('en');
|
|
457
612
|
const unit = 'minute';
|
|
458
613
|
const hash = {hash: {localeMatcher: "best fit", numeric: "always", style: "long", unit: unit}};
|
|
@@ -462,7 +617,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
462
617
|
|
|
463
618
|
// -- Test second -- //
|
|
464
619
|
|
|
465
|
-
it('expect
|
|
620
|
+
it('expect _dateDiff to return "in 1 second"', function () {
|
|
466
621
|
i18next.changeLanguage('en');
|
|
467
622
|
const unit = 'second';
|
|
468
623
|
const hash = {hash: {localeMatcher: "best fit", numeric: "always", style: "long", unit: unit}};
|
|
@@ -470,7 +625,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
470
625
|
assert.equal(`in 1 ${unit}`, res);
|
|
471
626
|
});
|
|
472
627
|
|
|
473
|
-
it('expect
|
|
628
|
+
it('expect _dateDiff to return "1 second ago"', function () {
|
|
474
629
|
i18next.changeLanguage('en');
|
|
475
630
|
const unit = 'second';
|
|
476
631
|
const hash = {hash: {localeMatcher: "best fit", numeric: "always", style: "long", unit: unit}};
|
|
@@ -483,25 +638,25 @@ describe('handlebars-i18n Tests', function () {
|
|
|
483
638
|
Tests against function _num
|
|
484
639
|
****************************************/
|
|
485
640
|
|
|
486
|
-
it('
|
|
641
|
+
it('_num should return comma separated triples of decimals when language is "en"', function () {
|
|
487
642
|
i18next.changeLanguage('en');
|
|
488
643
|
const res = hI18n.helpers._num(4000000, {hash: {}});
|
|
489
644
|
assert.equal('4,000,000', res);
|
|
490
645
|
});
|
|
491
646
|
|
|
492
|
-
it('
|
|
647
|
+
it('_num should return dot separated triples of decimals when language is "de"', function () {
|
|
493
648
|
i18next.changeLanguage('de');
|
|
494
649
|
const res = hI18n.helpers._num(4000000, {hash: {}});
|
|
495
650
|
assert.equal('4.000.000', res);
|
|
496
651
|
});
|
|
497
652
|
|
|
498
|
-
it('
|
|
653
|
+
it('_num should return comma separated triples of decimals and 2 fraction digits"', function () {
|
|
499
654
|
i18next.changeLanguage('en');
|
|
500
655
|
const res = hI18n.helpers._num(4000000, {hash: {minimumFractionDigits: 2}});
|
|
501
656
|
assert.equal('4,000,000.00', res);
|
|
502
657
|
});
|
|
503
658
|
|
|
504
|
-
it('
|
|
659
|
+
it('_num should return dot separated triples of decimals and 2 fraction digits when language is "de"', function () {
|
|
505
660
|
i18next.changeLanguage('de');
|
|
506
661
|
const res = hI18n.helpers._num(4000000, {hash: {minimumFractionDigits: 2}});
|
|
507
662
|
assert.equal('4.000.000,00', res);
|
|
@@ -512,26 +667,26 @@ describe('handlebars-i18n Tests', function () {
|
|
|
512
667
|
Tests against function _price
|
|
513
668
|
****************************************/
|
|
514
669
|
|
|
515
|
-
it('
|
|
670
|
+
it('_currency should return price in € written in comma separated triples of decimals and 2 fraction digits with leading currency symbol', function () {
|
|
516
671
|
i18next.changeLanguage('en');
|
|
517
672
|
const res = hI18n.helpers._price(4000000, {hash: {}});
|
|
518
673
|
assert.equal('€4,000,000.00', res);
|
|
519
674
|
});
|
|
520
675
|
|
|
521
|
-
it('
|
|
676
|
+
it('_currency should return price in € written in dot separated triples of decimals and 2 fraction digits with trailing currency symbol', function () {
|
|
522
677
|
i18next.changeLanguage('de');
|
|
523
678
|
const res = hI18n.helpers._price(4000000, {hash: {}});
|
|
524
679
|
assert.isString(res);
|
|
525
680
|
assert.equal('4.000.000,00 €', res);
|
|
526
681
|
});
|
|
527
682
|
|
|
528
|
-
it('
|
|
683
|
+
it('_currency should return price in ¥ written in comma separated triples of decimals with leading currency symbol', function () {
|
|
529
684
|
i18next.changeLanguage('en');
|
|
530
685
|
const res = hI18n.helpers._price(4000000, {hash: {currency: 'JPY', maximumFractionDigits: 0}});
|
|
531
686
|
assert.equal('¥4,000,000', res);
|
|
532
687
|
});
|
|
533
688
|
|
|
534
|
-
it('
|
|
689
|
+
it('_currency should return price in ¥ written in comma separated triples of decimals with trailing currency symbol', function () {
|
|
535
690
|
i18next.changeLanguage('de');
|
|
536
691
|
const res = hI18n.helpers._price(4000000, {hash: {currency: 'JPY', maximumFractionDigits: 0}});
|
|
537
692
|
assert.equal('4.000.000 ¥', res);
|
|
@@ -606,7 +761,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
606
761
|
assert.isOk(res);
|
|
607
762
|
});
|
|
608
763
|
|
|
609
|
-
it('
|
|
764
|
+
it('_num should return Intl standard format (no fraction digits) after reset() being called', function () {
|
|
610
765
|
HandlebarsI18n.configure('en', 'NumberFormat', {minimumFractionDigits: 4});
|
|
611
766
|
i18next.changeLanguage('en');
|
|
612
767
|
HandlebarsI18n.reset();
|
|
@@ -619,7 +774,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
619
774
|
Tests for custom format configurations for function _date
|
|
620
775
|
********************************************************************/
|
|
621
776
|
|
|
622
|
-
it('
|
|
777
|
+
it('_date when called after configure() with defined custom format (year:2-digit) should return ' +
|
|
623
778
|
'date "95" when language is "en"', function () {
|
|
624
779
|
HandlebarsI18n.configure('en', 'DateTimeFormat', {year: "2-digit"}, 'my-custom-format');
|
|
625
780
|
i18next.changeLanguage('en');
|
|
@@ -627,7 +782,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
627
782
|
assert.equal('95', res);
|
|
628
783
|
});
|
|
629
784
|
|
|
630
|
-
it('
|
|
785
|
+
it('_date when called after configure() with defined custom format (year:numeric) given as ARRAY should return ' +
|
|
631
786
|
'date "12/17/95" when language is "en"', function () {
|
|
632
787
|
HandlebarsI18n.configure(['en', 'DateTimeFormat', {year: "numeric"}, 'my-custom-format']);
|
|
633
788
|
i18next.changeLanguage('en');
|
|
@@ -635,7 +790,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
635
790
|
assert.equal('95', res);
|
|
636
791
|
});
|
|
637
792
|
|
|
638
|
-
it('
|
|
793
|
+
it('_date when called after configure() with defined custom format (year:2-digit) should override ' +
|
|
639
794
|
'standard configuration when language is "en"', function () {
|
|
640
795
|
HandlebarsI18n.configure([
|
|
641
796
|
['en', 'DateTimeFormat', {year: "numeric"}],
|
|
@@ -646,7 +801,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
646
801
|
assert.equal('95', res);
|
|
647
802
|
});
|
|
648
803
|
|
|
649
|
-
it('
|
|
804
|
+
it('_date when called after configure() with defined custom format (year:2-digit) should override ' +
|
|
650
805
|
'standard configuration also when being defined first', function () {
|
|
651
806
|
HandlebarsI18n.configure([
|
|
652
807
|
['en', 'DateTimeFormat', {year: "2-digit"}, 'my-custom-format'],
|
|
@@ -657,7 +812,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
657
812
|
assert.equal('95', res);
|
|
658
813
|
});
|
|
659
814
|
|
|
660
|
-
it('
|
|
815
|
+
it('_date when called after configure() should fall back to generic language format "en" when custom format is unknown' +
|
|
661
816
|
'standard configuration also when being defined first', function () {
|
|
662
817
|
HandlebarsI18n.configure([
|
|
663
818
|
['en', 'DateTimeFormat', {year: "2-digit"}, 'my-custom-format'],
|
|
@@ -668,7 +823,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
668
823
|
assert.equal('1995', res);
|
|
669
824
|
});
|
|
670
825
|
|
|
671
|
-
it('
|
|
826
|
+
it('_date when called after configure() should fall back to generic language format "all" when custom format is unknown' +
|
|
672
827
|
'standard configuration also when being defined first', function () {
|
|
673
828
|
HandlebarsI18n.configure([
|
|
674
829
|
['all', 'DateTimeFormat', {year: "2-digit"}, 'my-custom-format'],
|
|
@@ -679,7 +834,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
679
834
|
assert.equal('1995', res);
|
|
680
835
|
});
|
|
681
836
|
|
|
682
|
-
it('
|
|
837
|
+
it('_date when called after configure() should fall back to Intl default format when custom format is unknown' +
|
|
683
838
|
'standard configuration also when being defined first', function () {
|
|
684
839
|
HandlebarsI18n.reset();
|
|
685
840
|
HandlebarsI18n.configure([
|
|
@@ -695,7 +850,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
695
850
|
Tests for custom format configurations for _dateRel / _dateDiff
|
|
696
851
|
********************************************************************/
|
|
697
852
|
|
|
698
|
-
it('
|
|
853
|
+
it('_dateRel called after configure() with defined "all" (style: "long", unit: "second") should return ' +
|
|
699
854
|
'"in 12 seconds" when language is "en"', function () {
|
|
700
855
|
HandlebarsI18n.configure('all', 'RelativeTimeFormat', {style: "long", unit: "second"});
|
|
701
856
|
i18next.changeLanguage('en');
|
|
@@ -703,7 +858,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
703
858
|
assert.equal('in 12 seconds', res);
|
|
704
859
|
});
|
|
705
860
|
|
|
706
|
-
it('
|
|
861
|
+
it('_dateRel called after configure() with defined custom format (style: "long", unit: "year") should return ' +
|
|
707
862
|
'"in 12 Jahren" when language is "de"', function () {
|
|
708
863
|
HandlebarsI18n.configure('de', 'RelativeTimeFormat', {style: "long", unit: "year"}, 'date-rel-custom');
|
|
709
864
|
i18next.changeLanguage('de');
|
|
@@ -711,7 +866,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
711
866
|
assert.equal('in 12 Jahren', res);
|
|
712
867
|
});
|
|
713
868
|
|
|
714
|
-
it('
|
|
869
|
+
it('_dateRel called after configure() with defined custom format { style: "short", unit: "minutes" } should override ' +
|
|
715
870
|
'standard configuration when language is "en"', function () {
|
|
716
871
|
HandlebarsI18n.configure([
|
|
717
872
|
['en', 'RelativeTimeFormat', {style: "short", unit: "day"}, 'date-rel-spec'],
|
|
@@ -722,7 +877,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
722
877
|
assert.equal('in 12 days', res);
|
|
723
878
|
});
|
|
724
879
|
|
|
725
|
-
it('
|
|
880
|
+
it('_dateRel called after configure() with defined custom format { style: "short", unit: "minutes" } should override ' +
|
|
726
881
|
'standard configuration when language is "en" and output: \'in 12 days\'', function () {
|
|
727
882
|
HandlebarsI18n.configure([
|
|
728
883
|
['en', 'RelativeTimeFormat', {style: "short", unit: "day"}, 'date-rel-spec'],
|
|
@@ -733,7 +888,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
733
888
|
assert.equal('in 12 days', res);
|
|
734
889
|
});
|
|
735
890
|
|
|
736
|
-
it('
|
|
891
|
+
it('_dateDiff called after configure() with defined custom format { style: "short", unit: "minutes" } should override ' +
|
|
737
892
|
'standard configuration when language is "en" and output: \'in in 1 yr.\'', function () {
|
|
738
893
|
HandlebarsI18n.configure([
|
|
739
894
|
['en', 'RelativeTimeFormat', {style: "short", unit: "year"}, 'date-rel-spec'],
|
|
@@ -749,7 +904,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
749
904
|
Tests for custom format configurations for function _num
|
|
750
905
|
********************************************************************/
|
|
751
906
|
|
|
752
|
-
it('
|
|
907
|
+
it('_num when called after configure() with defined custom format (minimumFractionDigits:4) should return ' +
|
|
753
908
|
'comma separated triples of decimals and 4 fraction of digits when language is "en"', function () {
|
|
754
909
|
HandlebarsI18n.configure('en', 'NumberFormat', {minimumFractionDigits: 4}, 'my-custom-format');
|
|
755
910
|
i18next.changeLanguage('en');
|
|
@@ -757,7 +912,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
757
912
|
assert.equal('4,000,000.0000', res);
|
|
758
913
|
});
|
|
759
914
|
|
|
760
|
-
it('
|
|
915
|
+
it('_num when called after configure() with defined custom format (minimumFractionDigits:4) given as ARRAY should return ' +
|
|
761
916
|
'comma separated triples of decimals and 4 fraction of digits when language is "en"', function () {
|
|
762
917
|
HandlebarsI18n.configure(['en', 'NumberFormat', {minimumFractionDigits: 4}, 'my-custom-format']);
|
|
763
918
|
i18next.changeLanguage('en');
|
|
@@ -765,7 +920,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
765
920
|
assert.equal('4,000,000.0000', res);
|
|
766
921
|
});
|
|
767
922
|
|
|
768
|
-
it('
|
|
923
|
+
it('_num when called after configure() with defined custom format (minimumFractionDigits:4) should override' +
|
|
769
924
|
'standard configuration when language is "en"', function () {
|
|
770
925
|
HandlebarsI18n.configure([
|
|
771
926
|
['en', 'NumberFormat', {maximumFractionDigits: 1}],
|
|
@@ -776,7 +931,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
776
931
|
assert.equal('4,000,000.0000', res);
|
|
777
932
|
});
|
|
778
933
|
|
|
779
|
-
it('
|
|
934
|
+
it('_num when called after configure() with defined custom format (minimumFractionDigits:4) should override' +
|
|
780
935
|
'standard configuration also when being defined first', function () {
|
|
781
936
|
HandlebarsI18n.configure([
|
|
782
937
|
['en', 'NumberFormat', {minimumFractionDigits: 4}, 'my-custom-format'],
|
|
@@ -787,7 +942,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
787
942
|
assert.equal('4,000,000.0000', res);
|
|
788
943
|
});
|
|
789
944
|
|
|
790
|
-
it('
|
|
945
|
+
it('_num when called after configure() should fall back to standard language format "en" when custom format is unknown', function () {
|
|
791
946
|
HandlebarsI18n.configure([
|
|
792
947
|
['en', 'NumberFormat', {minimumFractionDigits: 4}, 'my-custom-format'],
|
|
793
948
|
['en', 'NumberFormat', {minimumFractionDigits: 1}]
|
|
@@ -797,7 +952,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
797
952
|
assert.equal('4,000,000.0', res);
|
|
798
953
|
});
|
|
799
954
|
|
|
800
|
-
it('
|
|
955
|
+
it('_num when called after configure() should fall back to standard language format "all" when custom format is unknown', function () {
|
|
801
956
|
HandlebarsI18n.configure([
|
|
802
957
|
['en', 'NumberFormat', {minimumFractionDigits: 4}, 'my-custom-format'],
|
|
803
958
|
['all', 'NumberFormat', {minimumFractionDigits: 1}]
|
|
@@ -807,7 +962,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
807
962
|
assert.equal('4,000,000.0', res);
|
|
808
963
|
});
|
|
809
964
|
|
|
810
|
-
it('
|
|
965
|
+
it('_num when called after configure() should fall back to Intl default when custom format is unknown', function () {
|
|
811
966
|
HandlebarsI18n.reset();
|
|
812
967
|
HandlebarsI18n.configure([
|
|
813
968
|
['en', 'NumberFormat', {minimumFractionDigits: 4}, 'my-custom-format']
|
|
@@ -822,7 +977,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
822
977
|
Tests for custom format configurations for function _price
|
|
823
978
|
********************************************************************/
|
|
824
979
|
|
|
825
|
-
it('
|
|
980
|
+
it('_price when called after configure() with defined custom format (minimumFractionDigits:4) should return ' +
|
|
826
981
|
'comma separated triples of decimals and 4 fraction of digits when language is "en"', function () {
|
|
827
982
|
HandlebarsI18n.configure('en', 'PriceFormat', {currency: 'EUR', minimumFractionDigits: 3}, 'my-custom-format');
|
|
828
983
|
i18next.changeLanguage('en');
|
|
@@ -830,7 +985,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
830
985
|
assert.equal('€2.000', res);
|
|
831
986
|
});
|
|
832
987
|
|
|
833
|
-
it('
|
|
988
|
+
it('_price when called after configure() with defined custom format (minimumFractionDigits:4) should return ' +
|
|
834
989
|
'comma separated triples of decimals and 4 fraction of digits when language is "en"', function () {
|
|
835
990
|
HandlebarsI18n.configure('en', 'PriceFormat', {currency: 'EUR', minimumFractionDigits: 3}, 'my-custom-format');
|
|
836
991
|
i18next.changeLanguage('en');
|
|
@@ -838,7 +993,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
838
993
|
assert.equal('€2.000', res);
|
|
839
994
|
});
|
|
840
995
|
|
|
841
|
-
it('
|
|
996
|
+
it('_price when called after configure() with defined custom format (minimumFractionDigits:4) given as ARRAY should return ' +
|
|
842
997
|
'comma separated triples of decimals and 4 fraction of digits when language is "en"', function () {
|
|
843
998
|
HandlebarsI18n.configure(['en', 'PriceFormat', {currency: 'EUR', minimumFractionDigits: 3}, 'my-custom-format']);
|
|
844
999
|
i18next.changeLanguage('en');
|
|
@@ -846,7 +1001,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
846
1001
|
assert.equal('€2.000', res);
|
|
847
1002
|
});
|
|
848
1003
|
|
|
849
|
-
it('
|
|
1004
|
+
it('_price when called after configure() with defined custom format (minimumFractionDigits:3) should override' +
|
|
850
1005
|
'standard configuration when language is "en"', function () {
|
|
851
1006
|
HandlebarsI18n.configure([
|
|
852
1007
|
['en', 'PriceFormat', {currency: 'USD'}],
|
|
@@ -857,7 +1012,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
857
1012
|
assert.equal('€2.000', res);
|
|
858
1013
|
});
|
|
859
1014
|
|
|
860
|
-
it('
|
|
1015
|
+
it('_price when called after configure() with defined custom format (minimumFractionDigits:3) should override' +
|
|
861
1016
|
'standard configuration also when being defined first', function () {
|
|
862
1017
|
HandlebarsI18n.configure([
|
|
863
1018
|
['en', 'PriceFormat', {currency: 'EUR', minimumFractionDigits: 3}, 'my-custom-format'],
|
|
@@ -868,7 +1023,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
868
1023
|
assert.equal('€2.000', res);
|
|
869
1024
|
});
|
|
870
1025
|
|
|
871
|
-
it('
|
|
1026
|
+
it('_price when called after configure() should fall back to standard language format "en" when custom format is unknown', function () {
|
|
872
1027
|
HandlebarsI18n.configure([
|
|
873
1028
|
['en', 'PriceFormat', {currency: 'EUR', minimumFractionDigits: 3}, 'my-custom-format'],
|
|
874
1029
|
['en', 'PriceFormat', {currency: 'USD'}]
|
|
@@ -878,7 +1033,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
878
1033
|
assert.equal('$2.00', res);
|
|
879
1034
|
});
|
|
880
1035
|
|
|
881
|
-
it('
|
|
1036
|
+
it('_price when called after configure() should fall back to standard language format "all" when custom format is unknown', function () {
|
|
882
1037
|
HandlebarsI18n.configure([
|
|
883
1038
|
['en', 'PriceFormat', {currency: 'EUR', minimumFractionDigits: 3}, 'my-custom-format'],
|
|
884
1039
|
['all', 'PriceFormat', {currency: 'USD'}]
|
|
@@ -888,7 +1043,7 @@ describe('handlebars-i18n Tests', function () {
|
|
|
888
1043
|
assert.equal('$2.00', res);
|
|
889
1044
|
});
|
|
890
1045
|
|
|
891
|
-
it('
|
|
1046
|
+
it('_price when called after configure() should fall back to Intl default when custom format is unknown', function () {
|
|
892
1047
|
HandlebarsI18n.configure([
|
|
893
1048
|
['en', 'PriceFormat', {currency: 'EUR', minimumFractionDigits: 3}, 'my-custom-format']
|
|
894
1049
|
]);
|