diff --git a/test/client/recordUtil.js b/test/client/recordUtil.js index f6c4e60..c7a18b1 100644 --- a/test/client/recordUtil.js +++ b/test/client/recordUtil.js @@ -377,7 +377,7 @@ test('recordUtil.resolve', (t) => { }) test('recordUtil.resolveRecords()', (t) => { - t.plan(6) + t.plan(7) t.test(`${t.name} resolves same data cross-platform on laptop and android`, (t) => { t.plan(1) @@ -464,6 +464,36 @@ test('recordUtil.resolveRecords()', (t) => { t.deepEquals(resolved, expected, t.name) }) + t.test(`${t.name} Create + existing and Modify + existing: should be resolved to Modify`, (t) => { + // ... and data from Create should be dropped + t.plan(1) + const create = CreateRecord({ + objectId: recordBookmark.objectId, + objectData: 'bookmark', + bookmark: Object.assign( + {}, + props.bookmark, + { site: Object.assign({}, siteProps) } + ) + }) + + const existingObject = Object.assign({}, create) + existingObject.action = proto.actions.UPDATE + + const update = Object.assign({}, existingObject) + update.bookmark = Object.assign({}, existingObject.bookmark) + update.bookmark.site = Object.assign({}, existingObject.bookmark.site) + update.bookmark.site.customTitle += `-Updated` + + const input = [ + [create, existingObject], + [update, existingObject] + ] + const expected = [update] + const resolved = recordUtil.resolveRecords(input) + t.deepEquals(resolved, expected, t.name) + }) + t.test(`${t.name} resolves bookmark records with same parent folder`, (t) => { t.plan(1) const record = {