Browse Source

Add i18next provider to test renderer

master
meriadec 7 years ago
parent
commit
3f310c3f70
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 6
      src/__mocks__/render.js
  2. 2
      src/helpers/staticPath.js
  3. 2
      src/renderer/i18n/instanciate.js

6
src/__mocks__/render.js

@ -2,8 +2,10 @@ import React from 'react'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
import renderer from 'react-test-renderer' import renderer from 'react-test-renderer'
import { ThemeProvider } from 'styled-components' import { ThemeProvider } from 'styled-components'
import { I18nextProvider } from 'react-i18next'
import createStore from 'renderer/createStore' import createStore from 'renderer/createStore'
import i18n from 'renderer/i18n/electron'
import theme from 'styles/theme' import theme from 'styles/theme'
@ -11,9 +13,11 @@ export default function render(component, state) {
const store = createStore({ state }) const store = createStore({ state })
return renderer return renderer
.create( .create(
<I18nextProvider i18n={i18n} initialLanguage="en">
<Provider store={store}> <Provider store={store}>
<ThemeProvider theme={theme}>{component}</ThemeProvider> <ThemeProvider theme={theme}>{component}</ThemeProvider>
</Provider>, </Provider>
</I18nextProvider>,
) )
.toJSON() .toJSON()
} }

2
src/helpers/staticPath.js

@ -7,4 +7,4 @@ export default (__DEV__ && !STORYBOOK_ENV && NODE_ENV !== 'test'
? __static ? __static
: isRunningInAsar : isRunningInAsar
? __dirname.replace(/app\.asar$/, 'static') ? __dirname.replace(/app\.asar$/, 'static')
: !STORYBOOK_ENV ? `${__dirname}/../static` : 'static') : !STORYBOOK_ENV ? `${__dirname}/../../static` : 'static')

2
src/renderer/i18n/instanciate.js

@ -4,7 +4,7 @@ const commonConfig = {
fallbackLng: 'en', fallbackLng: 'en',
debug: false, debug: false,
react: { react: {
wait: true, wait: process.env.NODE_ENV !== 'test',
}, },
} }

Loading…
Cancel
Save