There was an error while loading. Please reload this page.
1 parent 7cd93e0 commit 0d9f69eCopy full SHA for 0d9f69e
src/__tests__/index.test.js
@@ -467,5 +467,26 @@ describe('reactTreeWalker', () => {
467
expect(actual).toEqual(expected)
468
})
469
470
+
471
+ it('supports forwardRef', () => {
472
+ class Foo extends ReactComponent {
473
+ render() {
474
+ return this.props.children
475
+ }
476
477
478
+ const Bar = React.forwardRef((props, ref) => <Foo ref={ref} {...props} />)
479
480
+ const tree = <Bar>foo</Bar>
481
482
+ const elements = []
483
+ return reactTreeWalker(tree, element => {
484
+ elements.push(element)
485
+ }).then(() => {
486
+ expect(elements.pop()).toBe('foo')
487
+ expect(elements.pop().type).toBe(Foo)
488
+ expect(elements.pop().type).toBe(Bar)
489
+ })
490
491
492
0 commit comments