Skip to content

Commit

Permalink
WIP: add more cases to remote change sorter
Browse files Browse the repository at this point in the history
  • Loading branch information
taratatach committed May 9, 2019
1 parent 76a9543 commit 64056f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion core/remote/change.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,12 @@ const sorter = (a, b) => {

// if there isnt 2 add paths, sort by del path
if (lower(deletedId(b), deletedId(a))) return aFirst
return bFirst
if (lower(deletedId(a), deletedId(b))) return bFirst

if (lower(createdId(a), deletedId(b))) return bFirst
if (lower(deletedId(a), createdId(b))) return aFirst

return 0
}

function sort(changes /*: Array<RemoteChange> */) /*: void */ {
Expand Down
8 changes: 4 additions & 4 deletions test/unit/remote/change.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('remote change sort', () => {
}
const a = [child, parent]
remoteChange.sort(a)
a.should.deepEqual([parent, child])
a.should.deepEqual([child, parent])
})

describe('sorts deleted before created for the same path', () => {
Expand Down Expand Up @@ -152,15 +152,15 @@ describe('remote change sort', () => {
// - conflicts before anything else on same id
// - deletion before addition on same id
changes.should.deepEqual([
alanInsuranceCardDeletion,
alanInsuranceCardAddition,
edfContract3Deletion,
digipostBouyguesBill,
edfContract1ConflictCreation,
edfContract1Addition,
edfContract2ConflictCreation,
edfContract2Addition,
edfContract3Deletion,
edfContract3Addition,
alanInsuranceCardDeletion,
alanInsuranceCardAddition,
netflixBillAddition,
photoAddition
])
Expand Down

0 comments on commit 64056f9

Please sign in to comment.