@mt-testutils/mount-hoc
v1.0.8
Published
A helper function for Jest unit tests that creates higher-order components
Downloads
6
Readme
mount-hoc
Helper function that:
- creates a mockStore with given state
- connects the component to the Redux store
- mounts a component with Enzyme
- allows to pass
contextTypes
, which will automatically added as props to the mounted component
Installation
npm install --save-dev @mt-testutils/mount-hoc
Usage
import mountHoc from '@mt-testutils/mount-hoc';
import myHoc from './myHoc';
// Props passed to the higher order component, defaults to {} if omitted
const props = {
someProp: 'some prop'
};
// Redux state, defaults to {} if omitted
const state = {
foo: 'bar'
};
// Component that is wrapped by the HOC, defaults to <div>wrapped</div>
const WrappedComponent = <h1>Hello!!1!</h1>;
mountHoc(myHoc, { props, state, WrappedComponent });
Change Log
- See CHANGELOG.md
Contribution Guidelines
- See CONTRIBUTING.md
License
Copyright © 2018 mobile.de GmbH