Created
January 3, 2020 14:41
-
-
Save dobleuber/f0364bfcea1e2c00bbd698a117ca59d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestContainer extends React.Componen{ | |
render () { | |
const {initialState = {}, children} = this.props; | |
return ( | |
<MemoryRouter | |
keyLength={0} | |
> | |
{ | |
children | |
} | |
</MemoryRouter> | |
) | |
} | |
} | |
export default TestContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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