forked from chbrown/rfc6902
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharrays.ts
49 lines (45 loc) · 782 Bytes
/
arrays.ts
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
import test from 'ava'
import {applyPatch, createPatch} from '../index'
import {clone} from '../util'
const pairs = [
[
['A', 'Z', 'Z'],
['A'],
],
[
['A', 'B'],
['B', 'A'],
],
[
[],
['A', 'B'],
],
[
['B', 'A', 'M'],
['M', 'A', 'A'],
],
[
['A', 'A', 'R'],
[],
],
[
['A', 'B', 'C'],
['B', 'C', 'D'],
],
[
['A', 'C'],
['A', 'B', 'C'],
],
[
['A', 'B', 'C'],
['A', 'Z'],
],
]
pairs.forEach(([input, output]) => {
test(`diff+patch: [${input}] => [${output}]`, t => {
const patch = createPatch(input, output)
const actual_output = clone(input)
applyPatch(actual_output, patch)
t.deepEqual(actual_output, output, 'should apply produced patch to arrive at output')
})
})