@@ -103,5 +103,41 @@ describe('.updatedDiff', () => {
103103 expect ( updatedDiff ( new Date ( '2016' ) , new Date ( '2016' ) ) ) . toEqual ( { } ) ;
104104 } ) ;
105105 } ) ;
106+
107+ describe ( 'object create null' , ( ) => {
108+ test ( 'returns right hand side value when given objects are different at root' , ( ) => {
109+ const lhs = Object . create ( null ) ;
110+ lhs . a = 1 ;
111+ const rhs = Object . create ( null ) ;
112+ rhs . a = 2 ;
113+ expect ( updatedDiff ( lhs , rhs ) ) . toEqual ( { a : 2 } ) ;
114+ } ) ;
115+
116+ test ( 'returns subset of right hand side value when sibling objects differ' , ( ) => {
117+ const lhs = Object . create ( null ) ;
118+ lhs . a = { b : 1 } ;
119+ lhs . c = 2 ;
120+ const rhs = Object . create ( null ) ;
121+ rhs . a = { b : 1 } ;
122+ rhs . c = 3 ;
123+ expect ( updatedDiff ( lhs , rhs ) ) . toEqual ( { c : 3 } ) ;
124+ } ) ;
125+
126+ test ( 'returns subset of right hand side value when nested values differ' , ( ) => {
127+ const lhs = Object . create ( null ) ;
128+ lhs . a = { b : 1 , c : 2 } ;
129+ const rhs = Object . create ( null ) ;
130+ rhs . a = { b : 1 , c : 3 } ;
131+ expect ( updatedDiff ( lhs , rhs ) ) . toEqual ( { a : { c : 3 } } ) ;
132+ } ) ;
133+
134+ test ( 'returns subset of right hand side with updated date' , ( ) => {
135+ const lhs = Object . create ( null ) ;
136+ lhs . date = new Date ( '2016' ) ;
137+ const rhs = Object . create ( null ) ;
138+ rhs . date = new Date ( '2017' ) ;
139+ expect ( updatedDiff ( lhs , rhs ) ) . toEqual ( { date : new Date ( '2017' ) } ) ;
140+ } ) ;
141+ } ) ;
106142 } ) ;
107143} ) ;
0 commit comments