-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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(entity): add 'setOne' method #2410
Conversation
Preview docs changes for 1d05fa5 at https://previews.ngrx.io/pr2410-1d05fa5/ |
const updatedBook = { | ||
id: TheGreatGatsby.id, | ||
title: 'A New Hope', | ||
description: undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please remove the description altogether? With description: undefined
even upsertOne
would behave the same way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can remove it, that is not a problem. But that is the only way to test if 'setOne' actually behaves in a way different from 'upsertOne'. I mean, without this 'undefined' the test does not make much sense. Does it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It actually does make more sense without that property. You can make a comment to be very explicit that we are updating the the entity that doesn't have that property and toEqual
does the deep equality check.
With the test as-is even adapter.upsertOne(updatedBook, withOne)
would pass.
I see that this PR is merged, I'd suggest to have a follow-up PR to adjust this test behavoir.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, we might have a misunderstanding here... Do you think we need to:
- remove line 429;
or - remove
description
property from theBook
interface altogether?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the line from 429 and replace with /* description property is not provided */
it('should let you replace an entity in the state with setOne()', () => { | ||
const withOne = adapter.addOne( | ||
TheGreatGatsby, | ||
adapter.addOne(AnimalFarm, adapter.addOne(AClockworkOrange, state)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adapter.addOne(AnimalFarm, adapter.addOne(AClockworkOrange, state)) | |
state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I understand this. The reason I'm adding three books to the collection here is to test that sorted adapter preserves the correct sorting order after a 'setOne' call. If I only have one book in the collection that is not checked anymore. Do you think that is okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yea, that makes sense! Perhaps rename the withOne
variable then tho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. That's a copy&paste error :(. Should be fixed now.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Closes #2369
Does this PR introduce a breaking change?