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

Add documentation about how to test #34

Closed
ccapndave opened this issue Aug 25, 2015 · 3 comments
Closed

Add documentation about how to test #34

ccapndave opened this issue Aug 25, 2015 · 3 comments

Comments

@ccapndave
Copy link

It would be really useful to have a section in the readme with an example of how to write unit tests for selectors. The obvious strategy is to have two functions for every selector; the selector and the pure function:

export const getAddition = (a, b) => a + b // test this one
export const additionSelector = createSelector([ aSelector, bSelector ], getAddition);

However, this can be quite annoying because (at least in my app) the pure functions are almost always only used within the selector so it means having to figure out a naming strategy, be extra careful for typos, have a bigger API footprint, etc. However, if testing the selectors directly are we going to run into subtle problems with memoization or anything like that? Does testing selectors directly even work as a concept?

Any advice appreciated!

@ellbee
Copy link
Collaborator

ellbee commented Aug 25, 2015

I have been testing selectors directly. I'm currently in the middle of rewriting the documentation at the moment, I'll get my thoughts straight on this topic and add them as a section to the readme as suggested. Keep an eye on the 1.0.0_WIP branch in the next few days.

This was referenced Aug 25, 2015
@bvaughn
Copy link

bvaughn commented Aug 31, 2015

👍 Nice suggestion @ccapndave. I am currently wondering about how to approach this myself.

@ellbee
Copy link
Collaborator

ellbee commented Sep 9, 2015

I put something in the docs about how I test selectors. Feedback is welcome if anyone has a better approach.

@ellbee ellbee closed this as completed Sep 9, 2015
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

No branches or pull requests

3 participants