forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocalizeTests.ts
60 lines (57 loc) · 2.01 KB
/
LocalizeTests.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import Onyx from 'react-native-onyx';
import CONST from '../../src/CONST';
import * as Localize from '../../src/libs/Localize';
import ONYXKEYS from '../../src/ONYXKEYS';
import waitForBatchedUpdates from '../utils/waitForBatchedUpdates';
describe('localize', () => {
beforeAll(() => {
Onyx.init({
keys: {NVP_PREFERRED_LOCALE: ONYXKEYS.NVP_PREFERRED_LOCALE},
initialKeyStates: {[ONYXKEYS.NVP_PREFERRED_LOCALE]: CONST.LOCALES.DEFAULT},
});
return waitForBatchedUpdates();
});
afterEach(() => Onyx.clear());
describe('formatList', () => {
test.each([
[
[],
{
[CONST.LOCALES.DEFAULT]: '',
[CONST.LOCALES.ES]: '',
},
],
[
['rory'],
{
[CONST.LOCALES.DEFAULT]: 'rory',
[CONST.LOCALES.ES]: 'rory',
},
],
[
['rory', 'vit'],
{
[CONST.LOCALES.DEFAULT]: 'rory and vit',
[CONST.LOCALES.ES]: 'rory y vit',
},
],
[
['rory', 'vit', 'jules'],
{
[CONST.LOCALES.DEFAULT]: 'rory, vit, and jules',
[CONST.LOCALES.ES]: 'rory, vit y jules',
},
],
[
['rory', 'vit', 'ionatan'],
{
[CONST.LOCALES.DEFAULT]: 'rory, vit, and ionatan',
[CONST.LOCALES.ES]: 'rory, vit e ionatan',
},
],
])('formatList(%s)', (input, {[CONST.LOCALES.DEFAULT]: expectedOutput, [CONST.LOCALES.ES]: expectedOutputES}) => {
expect(Localize.formatList(input)).toBe(expectedOutput);
return Onyx.set(ONYXKEYS.NVP_PREFERRED_LOCALE, CONST.LOCALES.ES).then(() => expect(Localize.formatList(input)).toBe(expectedOutputES));
});
});
});