@@ -565,11 +565,9 @@ describe('deep-diff', function() {
565
565
} ) ;
566
566
567
567
describe ( 'regression test for issue #70' , function ( ) {
568
- var lhs = { foo : undefined } ;
569
- var rhs = { } ;
570
568
571
- it ( 'should detect a difference' , function ( ) {
572
- var diff = deep . diff ( lhs , rhs ) ;
569
+ it ( 'should detect a difference with undefined property on lhs ' , function ( ) {
570
+ var diff = deep . diff ( { foo : undefined } , { } ) ;
573
571
574
572
expect ( diff . length ) . to . be ( 1 ) ;
575
573
@@ -580,6 +578,31 @@ describe('deep-diff', function() {
580
578
expect ( diff [ 0 ] . lhs ) . to . be ( undefined ) ;
581
579
582
580
} ) ;
581
+
582
+ it ( 'should detect a difference with undefined property on rhs' , function ( ) {
583
+ var diff = deep . diff ( { } , { foo : undefined } ) ;
584
+
585
+ expect ( diff . length ) . to . be ( 1 ) ;
586
+
587
+ expect ( diff [ 0 ] . kind ) . to . be ( 'N' ) ;
588
+ expect ( diff [ 0 ] . path ) . to . be . an ( 'array' ) ;
589
+ expect ( diff [ 0 ] . path ) . to . have . length ( 1 ) ;
590
+ expect ( diff [ 0 ] . path [ 0 ] ) . to . be ( 'foo' ) ;
591
+ expect ( diff [ 0 ] . rhs ) . to . be ( undefined ) ;
592
+
593
+ } ) ;
594
+ } ) ;
595
+
596
+ describe ( 'regression test for issue #98' , function ( ) {
597
+ var lhs = { foo : undefined } ;
598
+ var rhs = { foo : undefined } ;
599
+
600
+ it ( 'should not detect a difference with two undefined property values' , function ( ) {
601
+ var diff = deep . diff ( lhs , rhs ) ;
602
+
603
+ expect ( diff ) . to . be ( undefined ) ;
604
+
605
+ } ) ;
583
606
} ) ;
584
607
585
608
0 commit comments