@@ -16,6 +16,7 @@ describe('.diff', () => {
1616        [ 'object' ,  {  a : 1  } ] , 
1717        [ 'array' ,  [ 1 ] ] , 
1818        [ 'function' ,  ( )  =>  ( { } ) ] , 
19+         [ 'date' ,  new  Date ( ) ] , 
1920      ] ) . it ( 'returns empty object when given values of type %s are equal' ,  ( type ,  value )  =>  { 
2021        expect ( diff ( value ,  value ) ) . to . deep . equal ( { } ) ; 
2122      } ) ; 
@@ -34,6 +35,7 @@ describe('.diff', () => {
3435        [ '872983' ,  {  areaCode : '+44' ,  number : '872983'  } ] , 
3536        [ 100 ,  ( )  =>  ( { } ) ] , 
3637        [ ( )  =>  ( { } ) ,  100 ] , 
38+         [ new  Date ( '2017-01-01' ) ,  new  Date ( '2017-01-02' ) ] , 
3739      ] ) . it ( 'returns right hand side value when different to left hand side value (%s, %s)' ,  ( lhs ,  rhs )  =>  { 
3840        expect ( diff ( lhs ,  rhs ) ) . to . deep . equal ( rhs ) ; 
3941      } ) ; 
@@ -92,5 +94,24 @@ describe('.diff', () => {
9294        expect ( diff ( [ 1 ,  2 ,  3 ] ,  [ 1 ,  2 ,  3 ,  9 ] ) ) . to . deep . equal ( {  3 : 9  } ) ; 
9395      } ) ; 
9496    } ) ; 
97+ 
98+     describe ( 'date' ,  ( )  =>  { 
99+       const  lhs  =  new  Date ( '2016' ) ; 
100+       const  rhs  =  new  Date ( '2017' ) ; 
101+       it ( 'returns right hand side date when updated' ,  ( )  =>  { 
102+         expect ( diff ( {  date : lhs  } ,  {  date : rhs  } ) ) . to . deep . equal ( {  date : rhs  } ) ; 
103+         expect ( diff ( [ lhs ] ,  [ rhs ] ) ) . to . deep . equal ( {  0 : rhs  } ) ; 
104+       } ) ; 
105+ 
106+       it ( 'returns undefined when date deleted' ,  ( )  =>  { 
107+         expect ( diff ( {  date : lhs  } ,  { } ) ) . to . deep . equal ( {  date : undefined  } ) ; 
108+         expect ( diff ( [ lhs ] ,  [ ] ) ) . to . deep . equal ( {  0 : undefined  } ) ; 
109+       } ) ; 
110+ 
111+       it ( 'returns right hand side when date is added' ,  ( )  =>  { 
112+         expect ( diff ( { } ,  {  date : rhs  } ) ) . to . deep . equal ( {  date : rhs  } ) ; 
113+         expect ( diff ( [ ] ,  [ rhs ] ) ) . to . deep . equal ( {  0 : rhs  } ) ; 
114+       } ) ; 
115+     } ) ; 
95116  } ) ; 
96117} ) ; 
0 commit comments