mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-29 23:58:06 +01:00
1c4f2aab8f
* 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
50 lines
941 B
JavaScript
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())
|
|
}
|