Skip to content

Commit 98e5b5d

Browse files
committed
Add a regression test for #224
1 parent 61c9c35 commit 98e5b5d

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/components/connect.spec.js

+38
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,44 @@ describe('React', () => {
201201
expect(stub.props.pass).toEqual('through')
202202
})
203203

204+
it('should handle unexpected prop changes with forceUpdate()', () => {
205+
const store = createStore(() => ({}))
206+
207+
@connect(state => state)
208+
class ConnectContainer extends Component {
209+
render() {
210+
return (
211+
<Passthrough {...this.props} pass={this.props.bar} />
212+
)
213+
}
214+
}
215+
216+
class Container extends Component {
217+
constructor() {
218+
super()
219+
this.bar = 'baz'
220+
}
221+
222+
componentDidMount() {
223+
this.bar = 'foo'
224+
this.forceUpdate()
225+
this.c.forceUpdate()
226+
}
227+
228+
render() {
229+
return (
230+
<ProviderMock store={store}>
231+
<ConnectContainer bar={this.bar} ref={c => this.c = c} />
232+
</ProviderMock>
233+
)
234+
}
235+
}
236+
237+
const container = TestUtils.renderIntoDocument(<Container />)
238+
const stub = TestUtils.findRenderedComponentWithType(container, Passthrough)
239+
expect(stub.props.bar).toEqual('foo')
240+
})
241+
204242
it('should remove undefined props', () => {
205243
const store = createStore(() => ({}))
206244
let props = { x: true }

0 commit comments

Comments
 (0)