Skip to content

Commit 5befe04

Browse files
author
stefan.hausmann
committed
added test for ignoring non-react-context values passed as a prop to the component
1 parent 9f1edde commit 5befe04

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/components/connect.spec.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,36 @@ describe('React', () => {
15641564
expect(actualState).toEqual(expectedState)
15651565
})
15661566

1567+
it('should ignore non-react-context values that are passed as a prop to the component', () => {
1568+
class Container extends Component {
1569+
render() {
1570+
return <Passthrough />
1571+
}
1572+
}
1573+
1574+
const nonContext = { someProperty: {} }
1575+
1576+
let actualState
1577+
1578+
const expectedState = { foos: {} }
1579+
1580+
const decorator = connect(state => {
1581+
actualState = state
1582+
return {}
1583+
})
1584+
const Decorated = decorator(Container)
1585+
1586+
const store = createStore(() => expectedState)
1587+
1588+
rtl.render(
1589+
<ProviderMock store={store}>
1590+
<Decorated context={nonContext} />
1591+
</ProviderMock>
1592+
)
1593+
1594+
expect(actualState).toEqual(expectedState)
1595+
})
1596+
15671597
it('should throw an error if the store is not in the props or context', () => {
15681598
const spy = jest.spyOn(console, 'error').mockImplementation(() => {})
15691599

0 commit comments

Comments
 (0)