@@ -134,6 +134,7 @@ describe('getDiff', () => {
134
134
assert . equal ( differenceTo . a . to , null ) ;
135
135
} ) ;
136
136
137
+ // https://github.com/omgaz/diffler/issues/31
137
138
it ( 'should detect comparisons with defined undefined' , ( ) => {
138
139
const differenceFrom = diffler ( { a : undefined , b : 'things' } , { a : 'more' , b : 'things' } ) ;
139
140
const differenceTo = diffler ( { a : 'some' , b : 'things' } , { a : undefined , b : 'things' } ) ;
@@ -146,5 +147,38 @@ describe('getDiff', () => {
146
147
assert . equal ( differenceFrom . a . from , undefined ) ;
147
148
assert . equal ( differenceTo . a . to , undefined ) ;
148
149
} ) ;
150
+
151
+ // https://github.com/omgaz/diffler/issues/31
152
+ it ( 'should detect comparisons with arrays of mixed types' , ( ) => {
153
+ const difference = diffler ( { a : [ 1 ] , b : [ 'one' ] } , { a : [ 'one' ] , b : [ 1 ] } ) ;
154
+
155
+ assert . equal ( Object . keys ( difference ) . length , 2 ) ;
156
+
157
+ console . log ( difference ) ;
158
+
159
+ assert . equal ( difference . a [ 0 ] . from , '1' ) ;
160
+ assert . equal ( difference . a [ 0 ] . to , 'one' ) ;
161
+ assert . equal ( difference . b [ 0 ] . from , 'one' ) ;
162
+ assert . equal ( difference . b [ 0 ] . to , 1 ) ;
163
+ } ) ;
164
+
165
+ // https://github.com/omgaz/diffler/issues/31
166
+ it ( 'should detect comparisons with arrays of mixed primitives and objects' , ( ) => {
167
+ const difference = diffler (
168
+ { a : [ 'something' ] , b : [ { b : 'something' } ] } ,
169
+ { a : [ { a : 'something' } ] , b : [ 'something' ] } ,
170
+ ) ;
171
+
172
+ assert . equal ( Object . keys ( difference ) . length , 2 ) ;
173
+
174
+ assert . equal ( difference . a [ 0 ] . from , 'something' ) ;
175
+ assert . deepEqual ( difference . a [ 0 ] . to , {
176
+ a : 'something' ,
177
+ } ) ;
178
+ assert . deepEqual ( difference . b [ 0 ] . from , {
179
+ b : 'something' ,
180
+ } ) ;
181
+ assert . equal ( difference . b [ 0 ] . to , 'something' ) ;
182
+ } ) ;
149
183
} ) ;
150
184
} ) ;
0 commit comments