Skip to content

Commit 5db3ab8

Browse files
committed
Update tests
1 parent f65f2d4 commit 5db3ab8

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

tests/data/translations/en/common.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@
1717
"modifier_escaped": "{{va\\:lue; option\\:1:VA\\;\\{\\{LUE\\}\\}\\:1; option\\:2:VA\\;\\{\\{LUE\\}\\}\\:2; default:DEFAULT \\{\\{VALUE\\}\\}\\;}}",
1818
"preprocess": [
1919
{
20-
"test": "passed"
21-
}
20+
"test": {
21+
"array": "passed"
22+
}
23+
},
24+
"string",
25+
null,
26+
0,
27+
1,
28+
-1,
29+
true,
30+
false
2231
]
2332
}

tests/specs/instance.spec.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ describe('i18n instance', () => {
211211

212212
const $translations = translations.get();
213213

214-
expect($translations[initLocale]['common.preprocess.0.test']).toBe('passed');
214+
expect($translations[initLocale]['common.preprocess.0.test.array']).toBe('passed');
215215
});
216216
it('`preprocess` works when set to `preserveArrays`', async () => {
217217
const { loadTranslations, translations } = new i18n({ loaders, log, preprocess: 'preserveArrays' });
@@ -220,7 +220,16 @@ describe('i18n instance', () => {
220220

221221
const $translations = translations.get();
222222

223-
expect($translations[initLocale]['common.preprocess'][0].test).toBe('passed');
223+
expect($translations[initLocale]['common.preprocess']).toStrictEqual([
224+
{ 'test.array': 'passed' },
225+
'string',
226+
null,
227+
0,
228+
1,
229+
-1,
230+
true,
231+
false,
232+
]);
224233
});
225234
it('`preprocess` works when set to `none`', async () => {
226235
const { loadTranslations, translations, rawTranslations } = new i18n({ loaders, log, preprocess: 'none' });
@@ -231,7 +240,7 @@ describe('i18n instance', () => {
231240
const $rawTranslations = rawTranslations.get();
232241

233242
expect($translations).toStrictEqual($rawTranslations);
234-
expect($translations[initLocale].common.preprocess[0].test).toBe('passed');
243+
expect($translations[initLocale].common.preprocess[0].test.array).toBe('passed');
235244
});
236245
it('initializes properly with `initLocale`', async () => {
237246
const { initialized, loadConfig } = new i18n();

0 commit comments

Comments
 (0)