Skip to content

Commit e745f54

Browse files
committed
fix test
1 parent 7146e67 commit e745f54

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

tests/unit/onyxTest.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Onyx.init({
3131
[ONYX_KEYS.KEY_WITH_UNDERSCORE]: 'default',
3232
},
3333
skippableCollectionMemberIDs: ['skippable-id'],
34+
mergeAllPropsSnapshotKeys: [ONYX_KEYS.COLLECTION.ANIMALS],
3435
});
3536

3637
describe('Onyx', () => {
@@ -1445,13 +1446,17 @@ describe('Onyx', () => {
14451446

14461447
it('should update Snapshot when its data changed', async () => {
14471448
const cat = `${ONYX_KEYS.COLLECTION.ANIMALS}cat`;
1449+
const people = `${ONYX_KEYS.COLLECTION.PEOPLE}1`;
14481450
const snapshot1 = `${ONYX_KEYS.COLLECTION.SNAPSHOT}1`;
14491451

14501452
const initialValue = {name: 'Fluffy'};
1451-
const finalValue = {name: 'Kitty', nickName: 'Fitse'};
1453+
const finalValuePeople = {name: 'Kitty'};
1454+
const finalValueCat = {name: 'Kitty', nickName: 'Fitse'};
1455+
const onyxUpdate = {name: 'Kitty', nickName: 'Fitse'};
14521456

14531457
await Onyx.set(cat, initialValue);
1454-
await Onyx.set(snapshot1, {data: {[cat]: initialValue}});
1458+
await Onyx.set(people, initialValue);
1459+
await Onyx.set(snapshot1, {data: {[cat]: initialValue, [people]: initialValue}});
14551460

14561461
const callback = jest.fn();
14571462

@@ -1462,11 +1467,14 @@ describe('Onyx', () => {
14621467

14631468
await waitForPromisesToResolve();
14641469

1465-
await Onyx.update([{key: cat, value: finalValue, onyxMethod: Onyx.METHOD.MERGE}]);
1470+
await Onyx.update([
1471+
{key: cat, value: onyxUpdate, onyxMethod: Onyx.METHOD.MERGE},
1472+
{key: people, value: onyxUpdate, onyxMethod: Onyx.METHOD.MERGE},
1473+
]);
14661474

14671475
expect(callback).toBeCalledTimes(2);
1468-
expect(callback).toHaveBeenNthCalledWith(1, {data: {[cat]: initialValue}}, snapshot1);
1469-
expect(callback).toHaveBeenNthCalledWith(2, {data: {[cat]: finalValue}}, snapshot1);
1476+
expect(callback).toHaveBeenNthCalledWith(1, {data: {[cat]: initialValue, [people]: initialValue}}, snapshot1);
1477+
expect(callback).toHaveBeenNthCalledWith(2, {data: {[cat]: finalValueCat, [people]: finalValuePeople}}, snapshot1);
14701478
});
14711479

14721480
describe('update', () => {

0 commit comments

Comments
 (0)