This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathserialization.test.js
70 lines (64 loc) · 1.82 KB
/
serialization.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const assert = require('assert')
const {
serializeOperationBinary, deserializeOperationBinary,
serializeRemotePositionBinary, deserializeRemotePositionBinary
} = require('../lib/serialization')
suite('serialization/deserialization', () => {
test('inserts', () => {
const op = {
type: 'splice',
spliceId: {site: 1, seq: 2},
insertion: {
text: 'hello',
insertionClock: 3,
leftDependencyId: {site: 1, seq: 1},
offsetInLeftDependency: {row: 0, column: 5},
rightDependencyId: {site: 1, seq: 1},
offsetInRightDependency: {row: 0, column: 5},
},
deletion: {
leftDependencyId: {site: 1, seq: 1},
offsetInLeftDependency: {row: 0, column: 5},
rightDependencyId: {site: 1, seq: 1},
offsetInRightDependency: {row: 0, column: 5},
maxSeqsBySite: {
'1': 3,
'2': 5
}
}
}
assert.deepEqual(deserializeOperationBinary(serializeOperationBinary(op)), op)
})
test('undo', () => {
const op = {
type: 'undo',
spliceId: {site: 1, seq: 3},
undoCount: 3
}
assert.deepEqual(deserializeOperationBinary(serializeOperationBinary(op)), op)
})
test('marker updates', () => {
const op = {
type: 'markers-update',
siteId: 1,
updates: {
1: {
1: {
range: {
startDependencyId: {site: 1, seq: 1},
offsetInStartDependency: {row: 0, column: 1},
endDependencyId: {site: 1, seq: 1},
offsetInEndDependency: {row: 0, column: 6}
},
exclusive: false,
reversed: false,
tailed: true
},
2: null
},
2: null
}
}
assert.deepEqual(deserializeOperationBinary(serializeOperationBinary(op)), op)
})
})