Skip to content

Commit 64056f9

Browse files
committed
WIP: add more cases to remote change sorter
1 parent 76a9543 commit 64056f9

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

core/remote/change.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,12 @@ const sorter = (a, b) => {
280280

281281
// if there isnt 2 add paths, sort by del path
282282
if (lower(deletedId(b), deletedId(a))) return aFirst
283-
return bFirst
283+
if (lower(deletedId(a), deletedId(b))) return bFirst
284+
285+
if (lower(createdId(a), deletedId(b))) return bFirst
286+
if (lower(deletedId(a), createdId(b))) return aFirst
287+
288+
return 0
284289
}
285290

286291
function sort(changes /*: Array<RemoteChange> */) /*: void */ {

test/unit/remote/change.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('remote change sort', () => {
1616
}
1717
const a = [child, parent]
1818
remoteChange.sort(a)
19-
a.should.deepEqual([parent, child])
19+
a.should.deepEqual([child, parent])
2020
})
2121

2222
describe('sorts deleted before created for the same path', () => {
@@ -152,15 +152,15 @@ describe('remote change sort', () => {
152152
// - conflicts before anything else on same id
153153
// - deletion before addition on same id
154154
changes.should.deepEqual([
155-
alanInsuranceCardDeletion,
156-
alanInsuranceCardAddition,
155+
edfContract3Deletion,
157156
digipostBouyguesBill,
158157
edfContract1ConflictCreation,
159158
edfContract1Addition,
160159
edfContract2ConflictCreation,
161160
edfContract2Addition,
162-
edfContract3Deletion,
163161
edfContract3Addition,
162+
alanInsuranceCardDeletion,
163+
alanInsuranceCardAddition,
164164
netflixBillAddition,
165165
photoAddition
166166
])

0 commit comments

Comments
 (0)