Skip to content
Snippets Groups Projects
Commit ae9c8644 authored by Chris Beer's avatar Chris Beer
Browse files

Mock withTranslations as per https://react.i18next.com/misc/testing

parent 005357c6
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,8 @@ import { App } from '../../../src/components/App';
import settings from '../../../src/config/settings';
import i18n from '../../../src/i18n';
jest.unmock('react-i18next');
/** */
function createWrapper(props) {
return shallow(
......
import ReactDOM from 'react-dom';
import MiradorViewer from '../../../src/lib/MiradorViewer';
jest.unmock('react-i18next');
describe('MiradorViewer', () => {
let instance;
beforeAll(() => {
......
......@@ -32,3 +32,13 @@ global.IntersectionObserver = IntersectionObserverPolyfill;
global.Image = window.Image;
Enzyme.configure({ adapter: new Adapter() });
jest.mock('react-i18next', () => ({
// this mock makes sure any components using the translate HoC receive the t function as a prop
withTranslation: () => (Component) => {
Component.defaultProps = { // eslint-disable-line no-param-reassign
...Component.defaultProps, t: k => k,
};
return Component;
},
}));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment