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. 10
      src/__mocks__/render.js
  2. 2
      src/helpers/staticPath.js
  3. 2
      src/renderer/i18n/instanciate.js

10
src/__mocks__/render.js

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

2
src/helpers/staticPath.js

@ -7,4 +7,4 @@ export default (__DEV__ && !STORYBOOK_ENV && NODE_ENV !== 'test'
? __static
: isRunningInAsar
? __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',
debug: false,
react: {
wait: true,
wait: process.env.NODE_ENV !== 'test',
},
}

Loading…
Cancel
Save