Repository navigation
Create a test case for mergecollection value check - #60
tugbadogan wants to merge 2 commits into
Conversation
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
| const onRender = jest.fn(); | ||
| render(<TestComponentWithOnyx onRender={onRender} />); | ||
| Onyx.mergeCollection(ONYX_KEYS.COLLECTION.TEST_KEY, {test_4: {ID: 456}, test_5: {ID: 567}}); | ||
| Onyx.mergeCollection(ONYX_KEYS.COLLECTION.TEST_KEY, {test_4: {Name: 'Test4'}, test_5: {Name: 'Test5'}, test_6: {ID: 678, Name: 'Test6'}}); |
There was a problem hiding this comment.
I see these two calls happening here and here.
This makes sense to me since mergeCollection() does not work the same way as merge so the assumption to treat the data the same was incorrect on my part. However, I'm unsure what would be the best way forward since Onyx.merge() does not require that we use prevState and the mechanism is a bit different.
See here:
Lines 452 to 513 in aa36bdb
The merge is batched and uses the data in localStorage as the source of truth so that when we call updateIndividualSubscriber() we will merge them together and then set the whole thing to state.
Probably the answer is to treat mergeCollection() similar to merge()? Another idea is that we can only use prevState when using mergeCollection(). Open to suggestions on the best way forward.
|
Hey @tugbadogan we're on somewhat of a tight deadline with this so I'm going to create the PR we will get you a bonus for catching this + helping write the test (which I'll include in the PR I'm drafting now). Thanks again! |
Related issue: Expensify/App#2225
Created a new test case for mergeCollection function to see if it merges values as expected. This test will fail.