Skip to content

Commit c4b13c2

Browse files
authored
BACKLOG-12240 add react-i18next mock to the test-framework (#77)
1 parent 4ea1311 commit c4b13c2

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

packages/test-framework/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
},
1919
"peerDependencies": {
2020
"jest": "^24.9.0",
21-
"babel-jest": "^24.9.1"
21+
"babel-jest": "^24.9.0"
2222
}
2323
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
3+
export const t = jest.fn(key => `translated_${key}`);
4+
5+
export const useTranslation = () => {
6+
return {
7+
t,
8+
i18n: {
9+
loadNamespaces: jest.fn()
10+
}
11+
};
12+
};
13+
14+
export const withTranslation = () => Component => props => {
15+
return <Component {...props} t={key => `translated_${key}`}/>;
16+
};

packages/test-framework/src/jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
moduleNameMapper: {
3-
'\\.(css|less|woff|woff2|eot|ttf)$': '<rootDir>/node_modules/@jahia/test-framework/build/js/__mocks__/styleMock.js'
3+
'\\.(css|less|woff|woff2|eot|ttf|svg)$': '<rootDir>/node_modules/@jahia/test-framework/build/js/__mocks__/styleMock.js',
4+
'^react-i18next$': '<rootDir>/node_modules/@jahia/test-framework/build/js/__mocks__/react-i18next.js'
45
},
56
setupFilesAfterEnv: [
67
'<rootDir>/node_modules/@jahia/test-framework/build/js/setupTests.js'

0 commit comments

Comments
 (0)