@@ -181,6 +181,17 @@ describe('defaultPropsHandler', () => {
181
181
expect ( documentation . displayName ) . toBe ( 'Foo' ) ;
182
182
} ) ;
183
183
184
+ it ( 'considers the variable name when handling forwardRef' , ( ) => {
185
+ const definition = statement (
186
+ [
187
+ 'var Foo = React.forwardRef(() => {});' ,
188
+ 'import React from "react";' ,
189
+ ] . join ( '\n' ) ,
190
+ ) . get ( 'declarations' , 0 , 'init' ) ;
191
+ expect ( ( ) => displayNameHandler ( documentation , definition ) ) . not . toThrow ( ) ;
192
+ expect ( documentation . displayName ) . toBe ( 'Foo' ) ;
193
+ } ) ;
194
+
184
195
it ( 'considers the variable name on assign' , ( ) => {
185
196
const definition = statement ( 'Foo = () => {};' ) . get (
186
197
'expression' ,
@@ -201,6 +212,17 @@ describe('defaultPropsHandler', () => {
201
212
expect ( documentation . displayName ) . toBe ( 'Foo' ) ;
202
213
} ) ;
203
214
215
+ it ( 'considers the variable name on assign when handling forwardRef call' , ( ) => {
216
+ const definition = statement (
217
+ [
218
+ 'Foo = React.forwardRef(() => {});' ,
219
+ 'import React from "react";' ,
220
+ ] . join ( '\n' ) ,
221
+ ) . get ( 'expression' , 'right' ) ;
222
+ expect ( ( ) => displayNameHandler ( documentation , definition ) ) . not . toThrow ( ) ;
223
+ expect ( documentation . displayName ) . toBe ( 'Foo' ) ;
224
+ } ) ;
225
+
204
226
it ( 'considers a static displayName object property over variable name' , ( ) => {
205
227
const definition = statement ( `
206
228
var Foo = () => {};
0 commit comments