Docs: Missing code example under the "Using Mock Selectors" section
Information
As I was going through the "Using Mock Selectors" section of the docs, I noticed that there seems to be a code example missing from the explanation. The explanation paragraph mentions the usage of the overrideSelector() method, but then in the code block below, doesn't actually give an example of the method being called in the code.
Because of this, I was pretty confused by the explanation until I found the live example link that is given below the paragraph after. Usage of overrideSelector() is very clear once you find the StackBlitz example, but I think it would be helpful to include another snippet in the docs itself just to make the explanation a little clearer.
It'd be a super easy fix. I'd suggest just adding the following code block from the StackBlitze example directly into the "Using Mock Selectors" section of the docs:
mockBooksSelector = store.overrideSelector(selectBooks, [
{
id: 'firstId',
volumeInfo: {
title: 'First Title',
authors: ['First Author'],
},
},
{
id: 'secondId',
volumeInfo: {
title: 'Second Title',
authors: ['Second Author'],
},
},
{
id: 'thirdId',
volumeInfo: {
title: 'Third Title',
authors: ['Third Author'],
},
},
{
id: 'fourthId',
volumeInfo: {
title: 'Fourth Title',
authors: ['Fourth Author'],
},
},
]);
mockBookCollectionSelector = store.overrideSelector(selectBookCollection, [
{
id: 'thirdId',
volumeInfo: {
title: 'Third Title',
authors: ['Third Author'],
},
},
]);
I think adding in this code block would make a world of difference for the clarity of the section. As soon as I saw it, the whole section made way more sense. Happy to make the change, if others think it's worthwhile.
Documentation page
https://ngrx.io/guide/store/testing#using-mock-selectors
I would be willing to submit a PR to fix this issue
- [X] Yes
- [ ] No
@mdemichele if you're still interested feel free to create a PR with the proposed change.
It does seem we forgot to add this example, making it unclear where mockBooksSelector and mockBookCollectionSelector are coming from.