Skip to content

Instantly share code, notes, and snippets.

@dobleuber
Created January 3, 2020 14:41
Show Gist options
  • Save dobleuber/f0364bfcea1e2c00bbd698a117ca59d1 to your computer and use it in GitHub Desktop.
Save dobleuber/f0364bfcea1e2c00bbd698a117ca59d1 to your computer and use it in GitHub Desktop.
class TestContainer extends React.Componen{
render () {
const {initialState = {}, children} = this.props;
return (
<MemoryRouter
keyLength={0}
>
{
children
}
</MemoryRouter>
)
}
}
export default TestContainer;
describe('test', () => {
test('test route', () => {
let wrapper = mount(
<TestContainer>
<MyComponent />
</TestContainer>
);
console.log(wrapper.instance().history) // prints undefined
});
test('test route', () => {
let wrapper = mount(
<MemoryRouter
keyLength={0}
>
<MyComponent />
</MemoryRouter>
);
console.log(wrapper.instance().history) // prints history object
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment