@@ -39,11 +39,26 @@ describe('typescript-react-function-component-props-handler', () => {
3939 expect ( doc . displayName ) . toBe ( 'TooltipTarget' ) ;
4040 } ) ;
4141
42- // Currently returns error for React.forwardRef(...) components
4342 test ( 'handles React.forwardRef(...) components - part 2' , ( ) => {
44- expect ( ( ) => parseFixture ( 'ForwardedButton.tsx' ) ) . toThrow (
45- "Cannot read properties of undefined (reading 'length')"
46- ) ;
43+ const doc = parseFixture ( 'ForwardedButton.tsx' ) ;
44+
45+ expect ( doc . displayName ) . toBe ( 'ForwardedButton' ) ;
46+ expect ( doc ) . toHaveProperty ( 'props' ) ;
47+ expect ( doc . props ) . toHaveProperty ( 'label' ) ;
48+ expect ( doc . props . label . tsType ) . toMatchObject ( { name : 'string' } ) ;
49+ expect ( doc . props . label . required ) . toBe ( true ) ;
50+ expect ( doc . props . label ) . toHaveProperty ( 'description' ) ;
51+ expect ( doc . props . label . description ) . toBe ( 'Text to show inside the button' ) ;
52+
53+ expect ( doc . props ) . toHaveProperty ( 'onClick' ) ;
54+ expect ( doc . props . onClick . tsType ) . toMatchObject ( { name : 'signature' } ) ;
55+ expect ( doc . props . onClick . tsType . type ) . toBe ( 'function' ) ;
56+ expect ( doc . props . onClick . tsType . raw ) . toBe ( '() => void' ) ;
57+ expect ( doc . props . onClick . tsType . signature ) . toMatchObject ( { arguments : [ ] , return : { name : 'void' } } ) ;
58+ expect ( doc . props . onClick . required ) . toBe ( false ) ;
59+
60+ expect ( doc . props . onClick ) . toHaveProperty ( 'description' ) ;
61+ expect ( doc . props . onClick . description ) . toBe ( 'Optional click handler' ) ;
4762 } ) ;
4863
4964 test ( 'handles React.FC<Props> components - AccessibleButton' , ( ) => {
0 commit comments