File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 6
6
*
7
7
*/
8
8
9
- import { parse , noopImporter } from '../../../tests/utils' ;
9
+ import {
10
+ parse ,
11
+ statement ,
12
+ noopImporter ,
13
+ makeMockImporter ,
14
+ } from '../../../tests/utils' ;
10
15
import isReactForwardRefCall from '../isReactForwardRefCall' ;
11
16
12
17
describe ( 'isReactForwardRefCall' , ( ) => {
@@ -15,6 +20,13 @@ describe('isReactForwardRefCall', () => {
15
20
return root . get ( 'body' , root . node . body . length - 1 , 'expression' ) ;
16
21
}
17
22
23
+ const mockImporter = makeMockImporter ( {
24
+ foo : statement ( `
25
+ export default React.forwardRef;
26
+ import React from 'react';
27
+ ` ) . get ( 'declaration' ) ,
28
+ } ) ;
29
+
18
30
describe ( 'built in React.forwardRef' , ( ) => {
19
31
it ( 'accepts forwardRef called on React' , ( ) => {
20
32
const def = parsePath ( `
@@ -85,5 +97,13 @@ describe('isReactForwardRefCall', () => {
85
97
` ) ;
86
98
expect ( isReactForwardRefCall ( def , noopImporter ) ) . toBe ( true ) ;
87
99
} ) ;
100
+
101
+ it ( 'can resolve forwardRef imported from an intermediate module' , ( ) => {
102
+ const def = parsePath ( `
103
+ import foo from "foo";
104
+ foo({});
105
+ ` ) ;
106
+ expect ( isReactForwardRefCall ( def , mockImporter ) ) . toBe ( true ) ;
107
+ } ) ;
88
108
} ) ;
89
109
} ) ;
You can’t perform that action at this time.
0 commit comments