@@ -13,6 +13,7 @@ describe('.diff', () => {
13
13
[ 'object' , { a : 1 } ] ,
14
14
[ 'array' , [ 1 ] ] ,
15
15
[ 'function' , ( ) => ( { } ) ] ,
16
+ [ 'NaN' , NaN ] ,
16
17
[ 'date' , new Date ( ) ] ,
17
18
[ 'date with milliseconds' , new Date ( '2017-01-01T00:00:00.637Z' ) ] ,
18
19
] ) ( 'returns empty object when given values of type %s are equal' , ( type , value ) => {
@@ -56,7 +57,7 @@ describe('.diff', () => {
56
57
} ) ;
57
58
58
59
test ( 'returns subset of right hand side value when nested values differ' , ( ) => {
59
- expect ( diff ( { a : { b : 1 , c : 2 } } , { a : { b : 1 , c : 3 } } ) ) . toEqual ( { a : { c : 3 } } ) ;
60
+ expect ( diff ( { a : { b : 1 , c : 2 } } , { a : { b : 1 , c : 3 } } ) ) . toEqual ( { a : { c : 3 } } ) ;
60
61
} ) ;
61
62
62
63
test ( 'returns subset of right hand side value when nested values differ at multiple paths' , ( ) => {
@@ -72,7 +73,7 @@ describe('.diff', () => {
72
73
} ) ;
73
74
74
75
test ( 'returns keys as undefined when deleted from right hand side' , ( ) => {
75
- expect ( diff ( { a : 1 , b : { c : 2 } } , { a : 1 } ) ) . toEqual ( { b : undefined } ) ;
76
+ expect ( diff ( { a : 1 , b : { c : 2 } } , { a : 1 } ) ) . toEqual ( { b : undefined } ) ;
76
77
} ) ;
77
78
} ) ;
78
79
@@ -139,7 +140,7 @@ describe('.diff', () => {
139
140
140
141
test ( 'returns subset of right hand side value when nested values differ' , ( ) => {
141
142
const lhs = Object . create ( null ) ;
142
- lhs . a = { b : 1 , c : 2 } ;
143
+ lhs . a = { b : 1 , c : 2 } ;
143
144
const rhs = Object . create ( null ) ;
144
145
rhs . a = { b : 1 , c : 3 } ;
145
146
expect ( diff ( lhs , rhs ) ) . toEqual ( { a : { c : 3 } } ) ;
@@ -173,5 +174,15 @@ describe('.diff', () => {
173
174
expect ( diff ( lhs , rhs ) ) . toEqual ( { b : 2 } ) ;
174
175
} ) ;
175
176
} ) ;
177
+
178
+ describe ( 'nested NaN' , ( ) => {
179
+ test ( 'returns empty object when there is nested NaN value' , ( ) => {
180
+ expect ( diff ( { a : 1 , b : NaN } , { a : 1 , b : NaN } ) ) . toEqual ( { } ) ;
181
+ } ) ;
182
+
183
+ test ( 'returns subset of right hand side when a left hand side value is not a NaN' , ( ) => {
184
+ expect ( diff ( { a : 1 , b : 2 } , { a : 1 , b : NaN } ) ) . toEqual ( { b : NaN } ) ;
185
+ } ) ;
186
+ } ) ;
176
187
} ) ;
177
188
} ) ;
0 commit comments