Skip to content

Commit

Permalink
add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
vedadeepta committed Oct 24, 2021
1 parent ac47d4b commit 65eb9b6
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions tests/lib/rules/prop-types.js
Expand Up @@ -3435,6 +3435,18 @@ ruleTester.run('prop-types', rule, {
`,
features: ['ts', 'no-babel'],
},
{
code: `
import React, { ForwardRefRenderFunction } from 'react'
type IfooProps = { e: string };
const Foo: ForwardRefRenderFunction<HTMLDivElement, IfooProps> = (props, ref) => {
const { e } = props;
return <div ref={ref}>hello</div>;
};
`,
features: ['ts', 'no-babel'],
},
{
code: `
import React from 'react'
Expand All @@ -3459,6 +3471,39 @@ ruleTester.run('prop-types', rule, {
`,
features: ['ts', 'no-babel'],
},
{
code: `
import React from 'react'
type IfooProps = { e: string };
const Foo= React.forwardRef<HTMLDivElement, IfooProps>(function Foo(props, ref) {
const { e } = props;
return <div ref={ref}>hello</div>;
});
`,
features: ['ts', 'no-babel'],
},
{
code: `
import React from 'react'
interface IfooProps { e: string }
const Foo= React.forwardRef<HTMLDivElement, IfooProps>(function Foo(props, ref) {
const { e } = props;
return <div ref={ref}>hello</div>;
});
`,
features: ['ts', 'no-babel'],
},
{
code: `
import React, { forwardRef } from 'react'
interface IfooProps { e: string }
const Foo= forwardRef<HTMLDivElement, IfooProps>(function Foo(props, ref) {
const { e } = props;
return <div ref={ref}>hello</div>;
});
`,
features: ['ts', 'no-babel'],
},
{
code: `
import React, { forwardRef as X } from 'react'
Expand Down Expand Up @@ -7235,6 +7280,42 @@ ruleTester.run('prop-types', rule, {
},
],
features: ['ts', 'no-babel'],
},
{
code: `
import React from 'react'
type IfooProps = { e: string };
const Foo= React.forwardRef<HTMLDivElement, IfooProps>(function Foo(props, ref) {
const { l } = props;
return <div ref={ref}>hello</div>;
});
`,
errors: [
{
messageId: 'missingPropType',
data: { name: 'l' },
},
],
features: ['ts', 'no-babel'],
},
{
code: `
import React, { forwardRef } from 'react'
type IfooProps = { e: string };
const Foo= forwardRef<HTMLDivElement, IfooProps>(function Foo(props, ref) {
const { l } = props;
return <div ref={ref}>hello</div>;
});
`,
errors: [
{
messageId: 'missingPropType',
data: { name: 'l' },
},
],
features: ['ts', 'no-babel'],
}
)),
});

0 comments on commit 65eb9b6

Please sign in to comment.