Skip to content

Instantly share code, notes, and snippets.

@johnthepink
Created November 15, 2016 17:07
Show Gist options
  • Save johnthepink/6013b83693693232ecc45138ecd40914 to your computer and use it in GitHub Desktop.
Save johnthepink/6013b83693693232ecc45138ecd40914 to your computer and use it in GitHub Desktop.
Mocking Mixin Class Methods
const MockHeaderAction = (Component) => (
class MockHeaderAction extends React.Component {
constructor () {
super(...arguments);
this.headerAction = jest.fn();
}
render() {
return <Component { ...this.props } { ...this.state } />
}
}
);
const generateComponent = (additionalProps = {}) => {
const newProps = {
...defaultProps,
...additionalProps,
};
const MockedDevotions = MockHeaderAction(Devotions);
return <MockedDevotions { ...newProps } />;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment