From ad1a66dbe1b70a1cd62f71608502e314f886ebc1 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 12 Jul 2023 13:52:00 -0600 Subject: [PATCH] fix tests --- lib/Onyx.js | 2 +- tests/unit/onyxTest.js | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/Onyx.js b/lib/Onyx.js index dbfb4899..2caa740e 100644 --- a/lib/Onyx.js +++ b/lib/Onyx.js @@ -1135,7 +1135,7 @@ function mergeCollection(collectionKey, collection) { return; } hasCollectionKeyCheckFailed = true; - Logger.logError(`Provided collection doesn't have all its data belonging to the same parent. CollectionKey: ${collectionKey}, DataKey: ${dataKey}`); + Logger.logAlert(`Provided collection doesn't have all its data belonging to the same parent. CollectionKey: ${collectionKey}, DataKey: ${dataKey}`); }); // Gracefully handle bad mergeCollection updates so it doesn't block the merge queue diff --git a/tests/unit/onyxTest.js b/tests/unit/onyxTest.js index cf269494..db4c429d 100644 --- a/tests/unit/onyxTest.js +++ b/tests/unit/onyxTest.js @@ -306,12 +306,18 @@ describe('Onyx', () => { }); }); - it('should throw error when a key not belonging to collection key is present in mergeCollection', () => { - try { - Onyx.mergeCollection(ONYX_KEYS.COLLECTION.TEST_KEY, {test_1: {ID: 123}, notMyTest: {beep: 'boop'}}); - } catch (error) { - expect(error.message).toEqual(`Provided collection doesn't have all its data belonging to the same parent. CollectionKey: ${ONYX_KEYS.COLLECTION.TEST_KEY}, DataKey: notMyTest`); - } + it('should skip the update when a key not belonging to collection key is present in mergeCollection', () => { + const valuesReceived = {}; + connectionID = Onyx.connect({ + key: ONYX_KEYS.COLLECTION.TEST_KEY, + initWithStoredValues: false, + callback: (data, key) => valuesReceived[key] = data, + }); + + return Onyx.mergeCollection(ONYX_KEYS.COLLECTION.TEST_KEY, {test_1: {ID: 123}, notMyTest: {beep: 'boop'}}) + .then(() => { + expect(valuesReceived).toEqual({}); + }); }); it('should return full object to callback when calling mergeCollection()', () => {