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

feat(store): add API to mock selectors #1688

Merged
merged 2 commits into from
Apr 4, 2019
Merged

Conversation

brandonroberts
Copy link
Member

Closes #1504

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Closes #1504

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Adds a MockStore#overrideSelector(string | selector) method that short-circuits returned values from selectors. Covers mocking different types of selectors:

store.select('slice');
const selector = createSelector(state, state => state.slice);
store.select(selector);
const selector = createSelector(state, state => state.slice);
store.pipe(select(selector));

@ngrxbot
Copy link
Collaborator

ngrxbot commented Apr 2, 2019

Preview docs changes for 2d9f8ac at https://previews.ngrx.io/pr1688-2d9f8ac/

@nasreddineskandrani
Copy link
Contributor

nasreddineskandrani commented Apr 2, 2019

i'll try it this week! amazing! thank you very much. I am introducing ngrx to a company and this will be really helpful!

Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

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

Neat! Just a few nits

modules/store/testing/src/mock_selector.ts Outdated Show resolved Hide resolved
modules/store/testing/src/mock_selector.ts Outdated Show resolved Hide resolved
modules/store/testing/src/mock_store.ts Show resolved Hide resolved
modules/store/testing/src/mock_store.ts Show resolved Hide resolved
@brandonroberts brandonroberts force-pushed the mock-store-selectors branch 2 times, most recently from 558b132 to 97e3534 Compare April 3, 2019 02:46
@ngrxbot
Copy link
Collaborator

ngrxbot commented Apr 3, 2019

Preview docs changes for 558b132 at https://previews.ngrx.io/pr1688-558b132/

@ngrxbot
Copy link
Collaborator

ngrxbot commented Apr 3, 2019

Preview docs changes for e9f13fe at https://previews.ngrx.io/pr1688-e9f13fe/

Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

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

👍

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.

Add mocking selectors to MockStore
5 participants