Skip to content

Commit 69e5c1e

Browse files
committed
test: one more scryRenderedComponentsWithType case
1 parent f9cc9fb commit 69e5c1e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/nerv-test-utils/__tests__/test.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,27 @@ describe('ReactTestUtils', () => {
259259
const hrs = ReactTestUtils.scryRenderedDOMComponentsWithTag(inst, 'hr')
260260
expect(hrs.length).toBe(2)
261261
})
262+
263+
it('scryRenderedComponentsWithType should works with multiple instances', () => {
264+
class Button extends React.Component {
265+
render () {
266+
return <button>{this.props.children}</button>
267+
}
268+
}
269+
270+
function Counter () {
271+
return (
272+
<div>
273+
<Button>+1</Button>
274+
<span>{1}</span>
275+
<Button>-1</Button>
276+
</div>
277+
)
278+
}
279+
280+
const inst = ReactTestUtils.renderIntoDocument(<Counter />)
281+
const btns = ReactTestUtils.scryRenderedComponentsWithType(inst, Button)
282+
283+
expect(btns.length).toBe(2)
284+
})
262285
})

0 commit comments

Comments
 (0)