@@ -50,7 +50,7 @@ test(header+'Changing property', function(t) {
50
50
var collector = dop . collect ( ) ;
51
51
set ( objectServer , 'one' , 11 ) ;
52
52
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 ) ;
54
54
maketest ( t , patchGenerated , patchExpected ) ;
55
55
} ) ;
56
56
@@ -70,7 +70,7 @@ test(header+'Changing property with the same value', function(t) {
70
70
71
71
test ( header + 'Deleting property' , function ( t ) {
72
72
var objectServer = dop . register ( { one :11 } ) ;
73
- var patchExpected = [ { one :undefined } ] ;
73
+ var patchExpected = [ { one :[ 0 ] } ] ;
74
74
var mutationsExpected = 1 ;
75
75
76
76
var collector = dop . collect ( ) ;
@@ -82,7 +82,7 @@ test(header+'Deleting property', function(t) {
82
82
83
83
test ( header + 'Change and delete a removed item' , function ( t ) {
84
84
var objectServer = dop . register ( { one :11 } ) ;
85
- var patchExpected = [ { two :2 , one :undefined } ] ;
85
+ var patchExpected = [ { two :2 , one :[ 0 ] } ] ;
86
86
var mutationsExpected = 3 ;
87
87
88
88
var collector = dop . collect ( ) ;
@@ -91,7 +91,7 @@ test(header+'Change and delete a removed item', function(t) {
91
91
set ( objectServer , 'two' , 2 ) ;
92
92
var patchGenerated = getPatch ( collector ) ;
93
93
t . equal ( collector . mutations . length , mutationsExpected , 'Mutations expecteds: ' + collector . mutations . length ) ;
94
- maketest ( t , patchGenerated , patchExpected ) ;
94
+ maketest ( t , patchGenerated , patchExpected , false ) ;
95
95
} ) ;
96
96
97
97
@@ -112,6 +112,20 @@ test(header+'Setting property array', function(t) {
112
112
113
113
114
114
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
+ } ) ;
115
129
116
130
117
131
@@ -125,7 +139,7 @@ test(header+'Setting an array and mutating it', function(t) {
125
139
var collector = dop . collect ( ) ;
126
140
127
141
128
- var patchExpected = [ { "array" :[ 0 , [ "c" , "b" , { "B1" :"string" } , false , true ] ] } ] ;
142
+ var patchExpected = [ { "array" :[ 1 , [ "c" , "b" , { "B1" :"string" } , false , true ] ] } ] ;
129
143
var mutationsExpected = 5 ;
130
144
set ( object , 'array' , [ true , false ] ) ;
131
145
object . array . push ( 'a' , 'b' , 'c' )
@@ -149,7 +163,7 @@ test(header+'Mutating array then mutating nested objects', function(t) {
149
163
var collector = dop . collect ( ) ;
150
164
151
165
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 } } ] ;
153
167
var mutationsExpected = 3 ;
154
168
object . array . reverse ( ) ;
155
169
set ( object . array , 2 , { B1 :false } ) ;
@@ -170,7 +184,7 @@ test(header+'Mutating nested objects then mutating parent array', function(t) {
170
184
var collector = dop . collect ( ) ;
171
185
172
186
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 ] ] } ] ;
174
188
var mutationsExpected = 3 ;
175
189
set ( object . array , 2 , { B1 :false } ) ;
176
190
object . array . reverse ( ) ;
@@ -191,7 +205,7 @@ test(header+'Mutating array twice', function(t) {
191
205
var collector = dop . collect ( ) ;
192
206
193
207
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 ] ] ] } ] ;
195
209
var mutationsExpected = 2 ;
196
210
object . array . push ( 5 , 4 , 6 ) ;
197
211
object . array . sort ( ) ;
@@ -211,7 +225,7 @@ test(header+'Mutating array and mutating array deeper', function(t) {
211
225
var collector = dop . collect ( ) ;
212
226
213
227
214
- var patchExpected = [ { "array" :[ 2 , [ 0 , 2 ] ] } , { "array" :{ "0" :[ 2 , [ 0 , 1 ] ] } } ] ;
228
+ var patchExpected = [ { "array" :[ 3 , [ 0 , 2 ] ] } , { "array" :{ "0" :[ 3 , [ 0 , 1 ] ] } } ] ;
215
229
var mutationsExpected = 2 ;
216
230
object . array . reverse ( ) ;
217
231
object . array [ 0 ] . reverse ( ) ;
@@ -230,7 +244,7 @@ test(header+'Mutating array deeper and mutating container', function(t) {
230
244
var collector = dop . collect ( ) ;
231
245
232
246
233
- var patchExpected = [ { "array" :{ "2" :[ 2 , [ 0 , 1 ] ] } } , { "array" :[ 2 , [ 0 , 2 ] ] } ] ;
247
+ var patchExpected = [ { "array" :{ "2" :[ 3 , [ 0 , 1 ] ] } } , { "array" :[ 3 , [ 0 , 2 ] ] } ] ;
234
248
var mutationsExpected = 2 ;
235
249
object . array [ 2 ] . reverse ( ) ;
236
250
object . array . reverse ( ) ;
0 commit comments