@@ -20,6 +20,33 @@ describe('deep-diff', function () {
20
20
expect ( deep . diff ( empty , { } ) ) . to . be . an ( 'undefined' ) ;
21
21
} ) ;
22
22
23
+ describe ( 'when compared to a different type of keyless object' , function ( ) {
24
+ var ctor = function ( ) {
25
+ this . foo = 'bar' ;
26
+ } ;
27
+ var comparandTuples = [ [ 'an array' , { key : [ ] } ] ,
28
+ [ 'an object' , { key : { } } ] ,
29
+ [ 'a date' , { key : new Date ( ) } ] ,
30
+ [ 'a null' , { key : null } ] ,
31
+ [ 'a regexp literal' , { key : / a / } ] ,
32
+ [ 'Math' , { key : Math } ] ] ;
33
+
34
+ comparandTuples . forEach ( function ( lhsTuple ) {
35
+ comparandTuples . forEach ( function ( rhsTuple ) {
36
+ if ( lhsTuple [ 0 ] === rhsTuple [ 0 ] ) {
37
+ return ;
38
+ }
39
+ it ( 'shows differences when comparing ' + lhsTuple [ 0 ] + ' to ' + rhsTuple [ 0 ] , function ( ) {
40
+ var diff = deep . diff ( lhsTuple [ 1 ] , rhsTuple [ 1 ] ) ;
41
+ expect ( diff ) . to . be . ok ( ) ;
42
+ expect ( diff . length ) . to . be ( 1 ) ;
43
+ expect ( diff [ 0 ] ) . to . have . property ( 'kind' ) ;
44
+ expect ( diff [ 0 ] . kind ) . to . be ( 'E' ) ;
45
+ } ) ;
46
+ } ) ;
47
+ } ) ;
48
+ } ) ;
49
+
23
50
describe ( 'when compared with an object having other properties' , function ( ) {
24
51
var comparand = { other : 'property' , another : 13.13 } ;
25
52
var diff = deep . diff ( empty , comparand ) ;
@@ -72,6 +99,14 @@ describe('deep-diff', function () {
72
99
expect ( diff [ 0 ] . kind ) . to . be ( 'E' ) ;
73
100
} ) ;
74
101
102
+ it ( 'shows the property as edited when compared to an array' , function ( ) {
103
+ var diff = deep . diff ( lhs , [ 'one' ] ) ;
104
+ expect ( diff ) . to . be . ok ( ) ;
105
+ expect ( diff . length ) . to . be ( 1 ) ;
106
+ expect ( diff [ 0 ] ) . to . have . property ( 'kind' ) ;
107
+ expect ( diff [ 0 ] . kind ) . to . be ( 'E' ) ;
108
+ } ) ;
109
+
75
110
} ) ;
76
111
77
112
describe ( 'A target that has null value' , function ( ) {
0 commit comments