A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ciphermask/test/lib/render-helpers.js

51 lines
1.0 KiB

import React from 'react'
import { mount } from 'enzyme'
import { MemoryRouter } from 'react-router-dom'
import PropTypes from 'prop-types'
6 years ago
export function mountWithStore (component, store) {
6 years ago
const context = {
store,
}
5 years ago
return mount(component, { context })
6 years ago
}
export function mountWithRouter (component, store = {}, pathname = '/') {
6 years ago
// Instantiate router context
const router = {
history: new MemoryRouter().history,
6 years ago
route: {
location: {
pathname: pathname,
},
6 years ago
match: {},
},
}
const createContext = () => ({
context: {
router,
t: (str) => str,
tOrKey: (str) => str,
metricsEvent: () => {},
store,
},
childContextTypes: {
router: PropTypes.object,
t: PropTypes.func,
tOrKey: PropTypes.func,
metricsEvent: PropTypes.func,
store: PropTypes.object,
},
6 years ago
})
const Wrapper = () => (
<MemoryRouter initialEntries={[{ pathname }]} initialIndex={0}>
{component}
</MemoryRouter>
)
return mount(<Wrapper />, createContext())
6 years ago
}