Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support passing store in via props for testing #44

Merged
merged 4 commits into from
Aug 9, 2015

Conversation

jhollingworth
Copy link
Contributor

Allow you to pass the redux store in via props to make it easier to unit test (Instead of having to mess with Provider's or contexts)

See also #38

Closes #33

@@ -72,7 +72,7 @@ export default function createConnect(React) {
static WrappedComponent = WrappedComponent;

static contextTypes = {
store: storeShape.isRequired
store: storeShape
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add similar propTypes then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

this.dispatchProps = computeDispatchProps(context);
this.store = props.store || context.store;

invariant(this.store, '`store` must be passed in via the context or props');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change it to

Could not find "store" in either context or props of "${this.constructor.displayName}". Either wrap the root component in a , or explicitly pass "store" as a prop to "${this.constructor.displayName}".

and also verify that the error message is correct in a unit test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated with test.

@gaearon gaearon merged commit 8bb6766 into reduxjs:master Aug 9, 2015
@gaearon
Copy link
Contributor

gaearon commented Aug 9, 2015

Thank you for your work on this. Released in 0.8.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants