mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
c11888f287
See [`no-empty-function`](https://eslint.org/docs/rules/no-empty-function) for more information. This change enables `no-empty-function` and fixes the issues raised by the rule.
49 lines
1022 B
JavaScript
49 lines
1022 B
JavaScript
import React from 'react'
|
|
import { mount } from 'enzyme'
|
|
import { MemoryRouter } from 'react-router-dom'
|
|
import PropTypes from 'prop-types'
|
|
|
|
export function mountWithStore (component, store) {
|
|
const context = {
|
|
store,
|
|
}
|
|
return mount(component, { context })
|
|
}
|
|
|
|
export function mountWithRouter (component, store = {}, pathname = '/') {
|
|
|
|
// Instantiate router context
|
|
const router = {
|
|
history: new MemoryRouter().history,
|
|
route: {
|
|
location: {
|
|
pathname: pathname,
|
|
},
|
|
match: {},
|
|
},
|
|
}
|
|
|
|
const createContext = () => ({
|
|
context: {
|
|
router,
|
|
t: (str) => str,
|
|
metricsEvent: () => undefined,
|
|
store,
|
|
},
|
|
childContextTypes: {
|
|
router: PropTypes.object,
|
|
t: PropTypes.func,
|
|
metricsEvent: PropTypes.func,
|
|
store: PropTypes.object,
|
|
},
|
|
})
|
|
|
|
const Wrapper = () => (
|
|
<MemoryRouter initialEntries={[{ pathname }]} initialIndex={0}>
|
|
{component}
|
|
</MemoryRouter>
|
|
)
|
|
|
|
return mount(<Wrapper />, createContext())
|
|
}
|