Skip to content
This repository has been archived by the owner on Jul 31, 2020. It is now read-only.

Commit

Permalink
Testcase for Create + existing and Modify + existing
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyBarabash committed Oct 21, 2019
1 parent 92884d9 commit b624090
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion test/client/recordUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit b624090

Please sign in to comment.