File tree 2 files changed +22
-0
lines changed
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,9 @@ export default function diff(
18
18
} ) ;
19
19
} else if (
20
20
obj [ key ] &&
21
+ newObj [ key ] &&
21
22
typeof obj [ key ] === "object" &&
23
+ typeof newObj [ key ] === "object" &&
22
24
! richTypes [ Object . getPrototypeOf ( obj [ key ] ) . constructor . name ]
23
25
) {
24
26
const nestedDiffs = diff ( obj [ key ] , newObj [ key ] ) ;
Original file line number Diff line number Diff line change @@ -29,4 +29,24 @@ test("remove raw value", () => {
29
29
] ) ;
30
30
} ) ;
31
31
32
+ test ( "replace object with null" , ( ) => {
33
+ assert . equal ( diff ( { object : { test : true } } , { object : null } ) , [
34
+ {
35
+ type : "CHANGE" ,
36
+ path : [ "object" ] ,
37
+ value : null ,
38
+ } ,
39
+ ] ) ;
40
+ } ) ;
41
+
42
+ test ( "replace object with other value" , ( ) => {
43
+ assert . equal ( diff ( { object : { test : true } } , { object : "string" } ) , [
44
+ {
45
+ type : "CHANGE" ,
46
+ path : [ "object" ] ,
47
+ value : "string" ,
48
+ } ,
49
+ ] ) ;
50
+ } ) ;
51
+
32
52
test . run ( ) ;
You can’t perform that action at this time.
0 commit comments