Adding to i18n mocks
This commit is contained in:
parent
79191c0fd7
commit
7a8a9836aa
@ -43,6 +43,7 @@
|
||||
},
|
||||
"collectCoverageFrom": [
|
||||
"src/**/*.js",
|
||||
"!src/i18n.js",
|
||||
"!src/prerender.js",
|
||||
"!src/setup/service-worker.js",
|
||||
"!src/setup/jest.js",
|
||||
|
20
src/__mocks__/i18n.js
Normal file
20
src/__mocks__/i18n.js
Normal file
@ -0,0 +1,20 @@
|
||||
import React from 'react';
|
||||
import i18n from 'i18next';
|
||||
import { I18nextProvider } from 'react-i18next';
|
||||
|
||||
const translate = txt => `translate(${ txt })`;
|
||||
|
||||
i18n.init({
|
||||
fallbackLng: 'en',
|
||||
fallbackNS: 'missing',
|
||||
debug: false,
|
||||
resources: {}
|
||||
});
|
||||
|
||||
const I18nWrapper = ({ children }) => ( // eslint-disable-line react/prop-types
|
||||
<I18nextProvider i18n={ i18n }>
|
||||
{ React.cloneElement(React.Children.only(children), { t: translate }) }
|
||||
</I18nextProvider>
|
||||
);
|
||||
|
||||
export { translate, i18n, I18nWrapper };
|
@ -1,2 +0,0 @@
|
||||
const translate = txt => `translate(${ txt })`;
|
||||
export default translate;
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import { Form } from 'components/Form';
|
||||
import translate from '__mocks__/translate';
|
||||
import { translate, I18nWrapper } from '__mocks__/i18n';
|
||||
|
||||
const syntaxes = {
|
||||
js: 'Javascript',
|
||||
|
@ -5,7 +5,7 @@ import { shallow } from 'enzyme';
|
||||
import Raven from 'raven-js';
|
||||
|
||||
import { RavenError } from 'components/RavenError';
|
||||
import translate from '__mocks__/translate';
|
||||
import { translate } from '__mocks__/i18n';
|
||||
|
||||
const testError = { error: 'test error' };
|
||||
const testDetails = { details: 'test details' };
|
||||
|
Loading…
Reference in New Issue
Block a user