From 65eb9b66cf668a827c50c7b37b4c754148505e93 Mon Sep 17 00:00:00 2001 From: vedadeepta Date: Sun, 24 Oct 2021 20:54:38 +0530 Subject: [PATCH] add test cases --- tests/lib/rules/prop-types.js | 81 +++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index b4cd3473b6..bef989d8f6 100644 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -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 = (props, ref) => { + const { e } = props; + return
hello
; + }; + `, + features: ['ts', 'no-babel'], + }, { code: ` import React from 'react' @@ -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(function Foo(props, ref) { + const { e } = props; + return
hello
; + }); + `, + features: ['ts', 'no-babel'], + }, + { + code: ` + import React from 'react' + interface IfooProps { e: string } + const Foo= React.forwardRef(function Foo(props, ref) { + const { e } = props; + return
hello
; + }); + `, + features: ['ts', 'no-babel'], + }, + { + code: ` + import React, { forwardRef } from 'react' + interface IfooProps { e: string } + const Foo= forwardRef(function Foo(props, ref) { + const { e } = props; + return
hello
; + }); + `, + features: ['ts', 'no-babel'], + }, { code: ` import React, { forwardRef as X } from 'react' @@ -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(function Foo(props, ref) { + const { l } = props; + return
hello
; + }); + `, + errors: [ + { + messageId: 'missingPropType', + data: { name: 'l' }, + }, + ], + features: ['ts', 'no-babel'], + }, + { + code: ` + import React, { forwardRef } from 'react' + + type IfooProps = { e: string }; + const Foo= forwardRef(function Foo(props, ref) { + const { l } = props; + return
hello
; + }); + `, + errors: [ + { + messageId: 'missingPropType', + data: { name: 'l' }, + }, + ], + features: ['ts', 'no-babel'], } )), });