@@ -207,15 +207,35 @@ describeWithDOM('Given the ComponentQueries library', () => {
207
207
const renderSpy = sinonSandbox . spy ( instance , 'render' ) ;
208
208
expect ( renderSpy . callCount ) . equals ( 0 ) ;
209
209
210
- // Change the width so that the queries produce a new result .
210
+ // Set the props causes a rerender .
211
211
mounted . setProps ( { size : { width : 150 } , foo : 'bar' } ) ;
212
212
expect ( renderSpy . callCount ) . equals ( 1 ) ;
213
213
214
- // Change the width so that the queries produce the same result .
215
- mounted . setProps ( { size : { width : 120 } , foo : 'bar' } ) ;
214
+ // Set the same props causes a rerender .
215
+ mounted . setProps ( { size : { width : 150 } , foo : 'bar' } ) ;
216
216
expect ( renderSpy . callCount ) . equals ( 2 ) ;
217
217
} ) ;
218
218
219
+ it ( 'Then it should pass the "other" props to the queries' , ( ) => {
220
+ let actualProps ;
221
+
222
+ const ComponentQueriedComponent = componentQueries (
223
+ ( _ , props ) => { actualProps = props ; return { } ; }
224
+ ) ( ( ) => < div /> ) ;
225
+
226
+ // Initial mount should call queries.
227
+ const expectedMountProps = { foo : 'bar' , baz : 1 } ;
228
+ const mounted = mount (
229
+ < ComponentQueriedComponent size = { { width : 50 } } { ...expectedMountProps } />
230
+ ) ;
231
+ expect ( actualProps ) . eql ( expectedMountProps ) ;
232
+
233
+ // Update should call queries with updated props.
234
+ const expectedUpdateProps = { foo : 'bob' , baz : 2 } ;
235
+ mounted . setProps ( Object . assign ( { } , { size : { width : 100 } } , expectedUpdateProps ) ) ;
236
+ expect ( actualProps ) . eql ( expectedUpdateProps ) ;
237
+ } ) ;
238
+
219
239
it ( 'Then height should be undefined if we are not monitoring height' , ( ) => {
220
240
let actualHeight ;
221
241
0 commit comments