1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/test/lib/render-helpers.js

44 lines
878 B
JavaScript
Raw Normal View History

import { shallow, mount } from 'enzyme'
import React from 'react'
2018-09-24 18:28:04 +02:00
import { BrowserRouter } from 'react-router-dom'
import { shape } from 'prop-types'
export function shallowWithStore (component, store) {
2018-09-24 18:28:04 +02:00
const context = {
store,
}
2019-12-03 21:50:55 +01:00
return shallow(component, { context })
2018-09-24 18:28:04 +02:00
}
export function mountWithStore (component, store) {
2018-09-24 18:28:04 +02:00
const context = {
store,
}
2019-12-03 21:50:55 +01:00
return mount(component, { context })
2018-09-24 18:28:04 +02:00
}
export function mountWithRouter (node) {
2018-09-24 18:28:04 +02:00
// Instantiate router context
const router = {
history: new BrowserRouter().history,
route: {
location: {},
match: {},
},
}
const createContext = () => ({
context: { router, t: () => {} },
childContextTypes: { router: shape({}), t: () => {} },
})
const Wrapper = () => (
<BrowserRouter>
{node}
</BrowserRouter>
)
return mount(<Wrapper />, createContext())
2018-09-24 18:28:04 +02:00
}