-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Add section on unit testing middleware to docs #559
Conversation
Rename conflicting variable
Add section on unit testing middleware to docs
Thanks |
Can we expand upon this part a little bit more? Like what's inside |
What is |
Yeah, it appears to be a fictional middleware that is referenced in the unit test examples, but not actually shown anywhere. |
Has anyone figured out how to implement |
@IndependentContractor my guess is that it'd either be one dispatch ever, or one dispatch per action type. let dispatched = false;
const singleDispatch = store => next => action => {
if (dispatched) return;
dispatched = true;
next(action);
} let dispatchedTypes = new Map();
const singleDispatch = store => next => action => {
if (dispatchedTypes.get(action.type)) return;
dispatchedTypes.set(action.type, true);
next(action);
} |
I'm going to take a stab at improving these docs. |
* writing tests for middleware example changed, #559 * note about mock impls * backticks to single quotes * better first test * semi * back ticks around `create`
* writing tests for middleware example changed, reduxjs#559 * note about mock impls * backticks to single quotes * better first test * semi * back ticks around `create`
Updated
WritingTests.md
with a section on how to test middleware.The function signature for middlware is a little confusing, so I think this could add a lot of value.