@@ -15,33 +15,41 @@ test('Inner encode', function (t) {
1515 const { encoded, decoded } = testEncodeDecode ( t , patch , expected )
1616} )
1717
18- // test('Escape', function (t) {
19- // const patch = { escape: { $w : [0, 1] } }
20- // const expected = { escape: { $escape: { $w : [0, 1] } } }
21- // testEncodeDecode(t, patch, expected)
22- // })
18+ test ( 'Escape' , function ( t ) {
19+ const patch = { escape : { $m : [ 0 , 1 ] } }
20+ const expected = { escape : { $escape : { $m : [ 0 , 1 ] } } }
21+ testEncodeDecode ( t , patch , expected )
22+ } )
2323
24- // test('Ignore', function (t) {
25- // const patch = { ignore: { $w : { a: 2 } } }
26- // const expected = { ignore: { $w : { a: 2 } } }
27- // testEncodeDecode(t, patch, expected)
28- // })
24+ test ( 'Ignore' , function ( t ) {
25+ const patch = { ignore : { $m : { a : 2 } } }
26+ const expected = { ignore : { $m : { a : 2 } } }
27+ testEncodeDecode ( t , patch , expected )
28+ } )
2929
30- // test('API', function (t) {
31- // const target = { array: ['a', 'b'] }
32- // const patch = { array: TYPE.Swap(0, 1) }
33- // const expected = { array: ['b', 'a'] }
34- // const { unpatch, result, mutations } = testPatchUnpatch(
35- // t,
36- // target,
37- // patch,
38- // expected
39- // )
40- // t.is(mutations.length, 1)
41- // t.is(result.array, target.array)
42- // t.true(unpatch.array instanceof TYPE.Swap)
43- // t.deepEqual(unpatch.array.args, [1, 0])
44- // })
30+ test ( 'API' , function ( t ) {
31+ const target = { array : [ 'a' , 'b' ] }
32+ const array = target . array
33+ const patch = {
34+ array : TYPE . Multi (
35+ TYPE . Splice ( 0 , 0 , 'c' ) ,
36+ TYPE . Swap ( 0 , 2 ) ,
37+ TYPE . Swap ( 1 , 2 )
38+ ) ,
39+ }
40+ const expected = { array : [ 'b' , 'c' , 'a' ] }
41+ const { unpatch, result, mutations } = testPatchUnpatch (
42+ t ,
43+ target ,
44+ patch ,
45+ expected
46+ )
47+ t . is ( mutations . length , 1 )
48+ t . is ( result . array , target . array )
49+ t . is ( array , target . array )
50+ t . true ( unpatch . array instanceof TYPE . Multi )
51+ t . is ( unpatch . array . values . length , 3 )
52+ } )
4553
4654test ( 'Deleting' , function ( t ) {
4755 const target = { array : false }
@@ -57,7 +65,7 @@ test('Adding array and swaping', function (t) {
5765 testPatchUnpatch ( t , target , patch , expected )
5866} )
5967
60- test ( 'Undefined before applying Multi' , function ( t ) {
68+ test ( 'Undefined before applying Multi' , function ( t ) {
6169 const target = { }
6270 const patch = { array : TYPE . Multi ( true ) }
6371 const expected = { array : true }
0 commit comments