@@ -50,7 +50,7 @@ test(header+'Changing property', function(t) {
5050 var collector = dop . collect ( ) ;
5151 set ( objectServer , 'one' , 11 ) ;
5252 var patchGenerated = getPatch ( collector ) ;
53- t . equal ( collector . mutations . length , 1 , 'Mutations expecteds: ' + collector . mutations . length ) ;
53+ t . equal ( collector . mutations . length , mutationsExpected , 'Mutations expecteds: ' + collector . mutations . length ) ;
5454 maketest ( t , patchGenerated , patchExpected ) ;
5555} ) ;
5656
@@ -70,7 +70,7 @@ test(header+'Changing property with the same value', function(t) {
7070
7171test ( header + 'Deleting property' , function ( t ) {
7272 var objectServer = dop . register ( { one :11 } ) ;
73- var patchExpected = [ { one :undefined } ] ;
73+ var patchExpected = [ { one :[ 0 ] } ] ;
7474 var mutationsExpected = 1 ;
7575
7676 var collector = dop . collect ( ) ;
@@ -82,7 +82,7 @@ test(header+'Deleting property', function(t) {
8282
8383test ( header + 'Change and delete a removed item' , function ( t ) {
8484 var objectServer = dop . register ( { one :11 } ) ;
85- var patchExpected = [ { two :2 , one :undefined } ] ;
85+ var patchExpected = [ { two :2 , one :[ 0 ] } ] ;
8686 var mutationsExpected = 3 ;
8787
8888 var collector = dop . collect ( ) ;
@@ -91,7 +91,7 @@ test(header+'Change and delete a removed item', function(t) {
9191 set ( objectServer , 'two' , 2 ) ;
9292 var patchGenerated = getPatch ( collector ) ;
9393 t . equal ( collector . mutations . length , mutationsExpected , 'Mutations expecteds: ' + collector . mutations . length ) ;
94- maketest ( t , patchGenerated , patchExpected ) ;
94+ maketest ( t , patchGenerated , patchExpected , false ) ;
9595} ) ;
9696
9797
@@ -112,6 +112,20 @@ test(header+'Setting property array', function(t) {
112112
113113
114114
115+ test ( header + 'Adding undefineds' , function ( t ) {
116+ var objectServer = dop . register ( { one :1 , array :[ ] } ) ;
117+ var patchExpected = [ { array : [ 2 , [ 0 , 0 , undefined ] ] , one :undefined , two :undefined } ] ;
118+ var mutationsExpected = 3 ;
119+
120+
121+ var collector = dop . collect ( ) ;
122+ set ( objectServer , 'one' , undefined ) ;
123+ set ( objectServer , 'two' , undefined ) ;
124+ objectServer . array . push ( undefined )
125+ var patchGenerated = getPatch ( collector ) ;
126+ t . equal ( collector . mutations . length , mutationsExpected , 'Mutations expecteds: ' + collector . mutations . length ) ;
127+ maketest ( t , patchGenerated , patchExpected ) ;
128+ } ) ;
115129
116130
117131
@@ -125,7 +139,7 @@ test(header+'Setting an array and mutating it', function(t) {
125139 var collector = dop . collect ( ) ;
126140
127141
128- var patchExpected = [ { "array" :[ 0 , [ "c" , "b" , { "B1" :"string" } , false , true ] ] } ] ;
142+ var patchExpected = [ { "array" :[ 1 , [ "c" , "b" , { "B1" :"string" } , false , true ] ] } ] ;
129143 var mutationsExpected = 5 ;
130144 set ( object , 'array' , [ true , false ] ) ;
131145 object . array . push ( 'a' , 'b' , 'c' )
@@ -149,7 +163,7 @@ test(header+'Mutating array then mutating nested objects', function(t) {
149163 var collector = dop . collect ( ) ;
150164
151165
152- var patchExpected = [ { "array" :[ 2 , [ 0 , 1 ] ] } , { "array" :{ "2" :[ 0 , { "B1" :false } ] , "length" :3 } } ] ;
166+ var patchExpected = [ { "array" :[ 3 , [ 0 , 1 ] ] } , { "array" :{ "2" :[ 1 , { "B1" :false } ] , "length" :3 } } ] ;
153167 var mutationsExpected = 3 ;
154168 object . array . reverse ( ) ;
155169 set ( object . array , 2 , { B1 :false } ) ;
@@ -170,7 +184,7 @@ test(header+'Mutating nested objects then mutating parent array', function(t) {
170184 var collector = dop . collect ( ) ;
171185
172186
173- var patchExpected = [ { "array" :{ "2" :[ 0 , { "B1" :false } ] , "length" :3 } } , { "array" :[ 2 , [ 0 , 2 ] ] } ] ;
187+ var patchExpected = [ { "array" :{ "2" :[ 1 , { "B1" :false } ] , "length" :3 } } , { "array" :[ 3 , [ 0 , 2 ] ] } ] ;
174188 var mutationsExpected = 3 ;
175189 set ( object . array , 2 , { B1 :false } ) ;
176190 object . array . reverse ( ) ;
@@ -191,7 +205,7 @@ test(header+'Mutating array twice', function(t) {
191205 var collector = dop . collect ( ) ;
192206
193207
194- var patchExpected = [ { "array" :[ [ 1 , [ 3 , 0 , 5 , 4 , 6 ] ] , [ 2 , [ 0 , 1 , 1 , 2 , 3 , 4 ] ] ] } ] ;
208+ var patchExpected = [ { "array" :[ [ 2 , [ 3 , 0 , 5 , 4 , 6 ] ] , [ 3 , [ 0 , 1 , 1 , 2 , 3 , 4 ] ] ] } ] ;
195209 var mutationsExpected = 2 ;
196210 object . array . push ( 5 , 4 , 6 ) ;
197211 object . array . sort ( ) ;
@@ -211,7 +225,7 @@ test(header+'Mutating array and mutating array deeper', function(t) {
211225 var collector = dop . collect ( ) ;
212226
213227
214- var patchExpected = [ { "array" :[ 2 , [ 0 , 2 ] ] } , { "array" :{ "0" :[ 2 , [ 0 , 1 ] ] } } ] ;
228+ var patchExpected = [ { "array" :[ 3 , [ 0 , 2 ] ] } , { "array" :{ "0" :[ 3 , [ 0 , 1 ] ] } } ] ;
215229 var mutationsExpected = 2 ;
216230 object . array . reverse ( ) ;
217231 object . array [ 0 ] . reverse ( ) ;
@@ -230,7 +244,7 @@ test(header+'Mutating array deeper and mutating container', function(t) {
230244 var collector = dop . collect ( ) ;
231245
232246
233- var patchExpected = [ { "array" :{ "2" :[ 2 , [ 0 , 1 ] ] } } , { "array" :[ 2 , [ 0 , 2 ] ] } ] ;
247+ var patchExpected = [ { "array" :{ "2" :[ 3 , [ 0 , 1 ] ] } } , { "array" :[ 3 , [ 0 , 2 ] ] } ] ;
234248 var mutationsExpected = 2 ;
235249 object . array [ 2 ] . reverse ( ) ;
236250 object . array . reverse ( ) ;
0 commit comments