@@ -117,5 +117,61 @@ describe('.diff', () => {
117
117
expect ( diff ( [ ] , [ rhs ] ) ) . toEqual ( { 0 : rhs } ) ;
118
118
} ) ;
119
119
} ) ;
120
+
121
+ describe ( 'object create null' , ( ) => {
122
+ test ( 'returns right hand side value when given objects are different' , ( ) => {
123
+ const lhs = Object . create ( null ) ;
124
+ lhs . a = 1 ;
125
+ const rhs = Object . create ( null ) ;
126
+ rhs . a = 2 ;
127
+ expect ( diff ( lhs , rhs ) ) . toEqual ( { a : 2 } ) ;
128
+ } ) ;
129
+
130
+ test ( 'returns subset of right hand side value when sibling objects differ' , ( ) => {
131
+ const lhs = Object . create ( null ) ;
132
+ lhs . a = { b : 1 } ;
133
+ lhs . c = 2 ;
134
+ const rhs = Object . create ( null ) ;
135
+ rhs . a = { b : 1 } ;
136
+ rhs . c = 3 ;
137
+ expect ( diff ( lhs , rhs ) ) . toEqual ( { c : 3 } ) ;
138
+ } ) ;
139
+
140
+ test ( 'returns subset of right hand side value when nested values differ' , ( ) => {
141
+ const lhs = Object . create ( null ) ;
142
+ lhs . a = { b : 1 , c : 2 } ;
143
+ const rhs = Object . create ( null ) ;
144
+ rhs . a = { b : 1 , c : 3 } ;
145
+ expect ( diff ( lhs , rhs ) ) . toEqual ( { a : { c : 3 } } ) ;
146
+ } ) ;
147
+
148
+ test ( 'returns subset of right hand side value when nested values differ at multiple paths' , ( ) => {
149
+ const lhs = Object . create ( null ) ;
150
+ lhs . a = { b : 1 } ;
151
+ lhs . c = 2 ;
152
+ const rhs = Object . create ( null ) ;
153
+ rhs . a = { b : 99 } ;
154
+ rhs . c = 3 ;
155
+ expect ( diff ( lhs , rhs ) ) . toEqual ( { a : { b : 99 } , c : 3 } ) ;
156
+ } ) ;
157
+
158
+ test ( 'returns subset of right hand side value when a key value has been deleted' , ( ) => {
159
+ const lhs = Object . create ( null ) ;
160
+ lhs . a = { b : 1 } ;
161
+ lhs . c = 2 ;
162
+ const rhs = Object . create ( null ) ;
163
+ rhs . a = { b : 1 } ;
164
+ expect ( diff ( lhs , rhs ) ) . toEqual ( { c : undefined } ) ;
165
+ } ) ;
166
+
167
+ test ( 'returns subset of right hand side value when a key value has been added' , ( ) => {
168
+ const lhs = Object . create ( null ) ;
169
+ lhs . a = 1 ;
170
+ const rhs = Object . create ( null ) ;
171
+ rhs . a = 1 ;
172
+ rhs . b = 2 ;
173
+ expect ( diff ( lhs , rhs ) ) . toEqual ( { b : 2 } ) ;
174
+ } ) ;
175
+ } ) ;
120
176
} ) ;
121
177
} ) ;
0 commit comments