Skip to content

Commit 74f93d6

Browse files
committed
Add a failing test for deep withRouter() updates
1 parent 72ed6e7 commit 74f93d6

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

modules/__tests__/withRouter-test.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('withRouter', function () {
1111
class App extends Component {
1212
render() {
1313
expect(this.props.router).toExist()
14-
return <h1>App</h1>
14+
return <h1>{this.props.router.location.pathname}</h1>
1515
}
1616
}
1717

@@ -39,4 +39,34 @@ describe('withRouter', function () {
3939
done()
4040
})
4141
})
42+
43+
it('updates the context inside static containers', function (done) {
44+
const WrappedApp = withRouter(App)
45+
46+
class StaticContainer extends Component {
47+
shouldComponentUpdate() {
48+
return false
49+
}
50+
51+
render() {
52+
return this.props.children
53+
}
54+
}
55+
56+
const history = createHistory('/')
57+
58+
render((
59+
<Router history={history}>
60+
<Route component={StaticContainer}>
61+
<Route path="/" component={WrappedApp} />
62+
<Route path="/hello" component={WrappedApp} />
63+
</Route>
64+
</Router>
65+
), node, function () {
66+
expect(node.firstChild.textContent).toEqual('/')
67+
history.push('/hello')
68+
expect(node.firstChild.textContent).toEqual('/hello')
69+
done()
70+
})
71+
})
4272
})

0 commit comments

Comments
 (0)