1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-26 05:13:37 +02:00
metamask-extension/test/lib/render-helpers.js
ricky 1c4f2aab8f React 16 upgrade (#7476)
* Use arrow property initializer functions

* Use pure components where applicable

* Add UNSAFE_ prefix for deprecated lifecycle hooks

* Add allow UNSAFE_

* Removed unused "Component"

* Replace boron with 'fade-modal'

* Upgrade react/no-deprecated to an error

* Paste react-tooltip-component source directly

* Use arrow functions to bind `this`

* Add UNSAFE_ prefix

* Update react-redux, react-router-dom

* Remove things from inlined 'fade-modal'

* Adjust mountWithRouter to get unit tests passing again

* Remove domkit

* Add Wrapper to render-helpers

* Upgrade @storybook/addon-knobs
2019-12-06 11:40:06 -04:00

50 lines
941 B
JavaScript

const { shallow, mount } = require('enzyme')
import React from 'react'
import { BrowserRouter } from 'react-router-dom'
import { shape } from 'prop-types'
module.exports = {
shallowWithStore,
mountWithStore,
mountWithRouter,
}
function shallowWithStore (component, store) {
const context = {
store,
}
return shallow(component, { context })
}
function mountWithStore (component, store) {
const context = {
store,
}
return mount(component, { context })
}
function mountWithRouter (node) {
// 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())
}