@@ -2,111 +2,111 @@ import test from 'ava'
22import { decode , TYPE } from '../'
33import { testEncodeDecode , testPatchUnpatch } from './utils'
44
5- test ( 'Valid type' , function ( t ) {
5+ test ( 'Valid type' , function ( t ) {
66 const patch = { convert : TYPE . Replace ( { hello : 'world' } ) }
77 const expected = { convert : { $r : { hello : 'world' } } }
88 testEncodeDecode ( t , patch , expected )
99} )
1010
11- test ( 'Escape' , function ( t ) {
11+ test ( 'Escape' , function ( t ) {
1212 const patch = { escape : { $r : 1 } }
1313 const expected = { escape : { $escape : { $r : 1 } } }
1414 testEncodeDecode ( t , patch , expected )
1515} )
1616
17- test ( 'Ignore' , function ( t ) {
17+ test ( 'Ignore' , function ( t ) {
1818 const patch = { ignore : { $r : 1 , $other : 1 } }
1919 const expected = { ignore : { $r : 1 , $other : 1 } }
2020 testEncodeDecode ( t , patch , expected )
2121} )
2222
23- test ( '$escaping' , function ( t ) {
23+ test ( '$escaping' , function ( t ) {
2424 const patch = {
2525 convert : TYPE . Replace ( [ 1 , 2 , 3 ] ) ,
26- escape : { $r : 1 }
26+ escape : { $r : 1 } ,
2727 }
2828 const expected = {
2929 convert : { $r : [ 1 , 2 , 3 ] } ,
30- escape : { $escape : { $r : 1 } }
30+ escape : { $escape : { $r : 1 } } ,
3131 }
3232 testEncodeDecode ( t , patch , expected )
3333} )
3434
35- test ( 'This should not be escaped because $r has another valid prop' , function ( t ) {
35+ test ( 'This should not be escaped because $r has another valid prop' , function ( t ) {
3636 const patch = {
3737 convert : TYPE . Replace ( [ 1 , 2 , 3 ] ) ,
38- ignored : { $r : [ 1 , 2 , 3 ] , $escape : [ 1 , 2 , 3 ] }
38+ ignored : { $r : [ 1 , 2 , 3 ] , $escape : [ 1 , 2 , 3 ] } ,
3939 }
4040 const expected = {
4141 convert : { $r : [ 1 , 2 , 3 ] } ,
42- ignored : { $r : [ 1 , 2 , 3 ] , $escape : [ 1 , 2 , 3 ] }
42+ ignored : { $r : [ 1 , 2 , 3 ] , $escape : [ 1 , 2 , 3 ] } ,
4343 }
4444 testEncodeDecode ( t , patch , expected )
4545} )
4646
47- test ( 'This should not be escaped because $r has another valid prop 2' , function ( t ) {
47+ test ( 'This should not be escaped because $r has another valid prop 2' , function ( t ) {
4848 const patch = {
4949 convert : TYPE . Replace ( [ 1 , 2 , 3 ] ) ,
50- escape : { $escape : [ 1 , 2 , 3 ] , $r : TYPE . Replace ( [ 1 , 2 , 3 ] ) }
50+ escape : { $escape : [ 1 , 2 , 3 ] , $r : TYPE . Replace ( [ 1 , 2 , 3 ] ) } ,
5151 }
5252 const expected = {
5353 convert : { $r : [ 1 , 2 , 3 ] } ,
54- escape : { $escape : [ 1 , 2 , 3 ] , $r : { $r : [ 1 , 2 , 3 ] } }
54+ escape : { $escape : [ 1 , 2 , 3 ] , $r : { $r : [ 1 , 2 , 3 ] } } ,
5555 }
5656 testEncodeDecode ( t , patch , expected )
5757} )
5858
59- test ( 'Decode alone' , function ( t ) {
59+ test ( 'Decode alone' , function ( t ) {
6060 const patch = {
6161 convert : { $r : [ 1 , 2 , 3 ] } ,
6262 string : { $r : 'string' } ,
6363 escape : { $escape : { $r : [ 1 , 2 , 3 ] } } ,
6464 ignore : {
6565 $escape : { $r : [ 1 , 2 , 3 ] } ,
66- two : { $r : [ 1 , 2 , 3 ] }
67- }
66+ two : { $r : [ 1 , 2 , 3 ] } ,
67+ } ,
6868 }
6969 const expected = {
7070 convert : TYPE . Replace ( [ 1 , 2 , 3 ] ) ,
7171 string : TYPE . Replace ( 'string' ) ,
7272 escape : { $r : [ 1 , 2 , 3 ] } ,
7373 ignore : {
7474 $escape : TYPE . Replace ( [ 1 , 2 , 3 ] ) ,
75- two : TYPE . Replace ( [ 1 , 2 , 3 ] )
76- }
75+ two : TYPE . Replace ( [ 1 , 2 , 3 ] ) ,
76+ } ,
7777 }
7878 t . deepEqual ( decode ( patch ) , expected )
7979} )
8080
81- test ( 'patch array' , function ( t ) {
81+ test ( 'patch array' , function ( t ) {
8282 const target = { value : { a : 1 , b : 2 } }
8383 const patch = { value : TYPE . Replace ( [ 1 , 2 , 3 ] ) }
8484 const expected = { value : [ 1 , 2 , 3 ] }
8585
8686 testPatchUnpatch ( t , target , patch , expected )
8787} )
8888
89- test ( 'patch object' , function ( t ) {
89+ test ( 'patch object' , function ( t ) {
9090 const target = { value : { a : 1 , b : 2 } }
9191 const patch = { value : TYPE . Replace ( { c : 3 } ) }
9292 const expected = { value : { c : 3 } }
9393
9494 testPatchUnpatch ( t , target , patch , expected )
9595} )
9696
97- test ( 'patch should replace the complete object' , function ( t ) {
97+ test ( 'patch should replace the complete object' , function ( t ) {
9898 const obj_to_replace = { c : 3 }
9999 const target = { value : { a : 1 , b : 2 } }
100100 const patch = { value : TYPE . Replace ( obj_to_replace ) }
101101 const expected = { value : { c : 3 } }
102102 const copyvalue = target . value
103103
104- testPatchUnpatch ( t , target , patch , expected , false )
104+ testPatchUnpatch ( t , target , patch , expected , false , false )
105105 t . is ( obj_to_replace , target . value )
106106 t . not ( copyvalue , target . value )
107107} )
108108
109- test ( 'testing that last test works correctly without replace' , function ( t ) {
109+ test ( 'testing that last test works correctly without replace' , function ( t ) {
110110 const target = { value : { a : 1 , b : 2 } }
111111 const patch = { value : { c : 3 } }
112112 const expected = { value : { a : 1 , b : 2 , c : 3 } }
@@ -118,15 +118,15 @@ test('testing that last test works correctly without replace', function(t) {
118118 t . deepEqual ( copyvalue , target . value )
119119} )
120120
121- test ( 'replace array' , function ( t ) {
121+ test ( 'replace array' , function ( t ) {
122122 const target = { value : { a : 1 , b : 2 } }
123123 const patch = TYPE . Replace ( [ 1 , 2 ] )
124124 const expected = [ 1 , 2 ]
125125
126126 testPatchUnpatch ( t , target , patch , expected )
127127} )
128128
129- test ( 'same behavior as replace array' , function ( t ) {
129+ test ( 'same behavior as replace array' , function ( t ) {
130130 const target = { value : { a : 1 , b : 2 } }
131131 const patch = [ 1 , 2 ]
132132 const expected = [ 1 , 2 ]
0 commit comments