Skip to content

Commit 5d05e4e

Browse files
jimbollatimdorr
authored andcommitted
Adds test to verify subs are called through a blocking component. (reduxjs#566)
1 parent 617f3c5 commit 5d05e4e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/components/connect.spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,5 +2125,29 @@ describe('React', () => {
21252125
expect(error).toInclude('InvalidMerge')
21262126
})
21272127

2128+
it('should notify nested components through a blocking component', () => {
2129+
@connect(state => ({ count: state }))
2130+
class Parent extends Component {
2131+
render() { return <BlockUpdates><Child /></BlockUpdates> }
2132+
}
2133+
2134+
class BlockUpdates extends Component {
2135+
shouldComponentUpdate() { return false; }
2136+
render() { return this.props.children; }
2137+
}
2138+
2139+
const mapStateToProps = expect.createSpy().andCall(state => ({ count: state }))
2140+
@connect(mapStateToProps)
2141+
class Child extends Component {
2142+
render() { return <div>{this.props.count}</div> }
2143+
}
2144+
2145+
const store = createStore((state = 0, action) => (action.type === 'INC' ? state + 1 : state))
2146+
TestUtils.renderIntoDocument(<ProviderMock store={store}><Parent /></ProviderMock>)
2147+
2148+
expect(mapStateToProps.calls.length).toBe(1)
2149+
store.dispatch({ type: 'INC' })
2150+
expect(mapStateToProps.calls.length).toBe(2)
2151+
})
21282152
})
21292153
})

0 commit comments

Comments
 (0)