-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathjest.setup.js
More file actions
35 lines (33 loc) · 882 Bytes
/
jest.setup.js
File metadata and controls
35 lines (33 loc) · 882 Bytes
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
/* eslint-disable */
// Mock Lingui's t function for tests
jest.mock('@lingui/core/macro', () => ({
t: jest.fn((obj) => {
if (typeof obj === 'object' && obj.message) {
return obj.message;
}
return obj;
}),
plural: jest.fn((count, obj) => {
if (typeof obj === 'object') {
// For plural, return 'one' if count is 1, otherwise 'other'
const form = count === 1 ? 'one' : 'other';
const message = obj[form] || obj.other || obj.one || '';
// Replace # placeholder with the actual count
return message.replace(/#/g, count);
}
return obj;
}),
}));
// Mock Lingui's i18n instance
jest.mock('@lingui/core', () => ({
i18n: {
_: jest.fn((obj) => {
if (typeof obj === 'object' && obj.message) {
return obj.message;
}
return obj;
}),
activate: jest.fn(),
load: jest.fn(),
},
}));