From 7f53b5673f64ff72a54c19b0685f901cfec96b03 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sun, 3 Oct 2021 15:14:51 +0200 Subject: [PATCH] fix(render): Don't reject wrapper types based on statics (#973) --- types/index.d.ts | 2 +- types/test.tsx | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 3baf7b5e..92eb2d7b 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -70,7 +70,7 @@ export interface RenderOptions< * * @see https://testing-library.com/docs/react-testing-library/api/#wrapper */ - wrapper?: React.ComponentType<{children: React.ReactElement}> + wrapper?: React.JSXElementConstructor<{children: React.ReactElement}> } type Omit = Pick> diff --git a/types/test.tsx b/types/test.tsx index 7c45eaae..71ea30a9 100644 --- a/types/test.tsx +++ b/types/test.tsx @@ -115,13 +115,32 @@ export function wrappedRenderB( ui: React.ReactElement, options?: pure.RenderOptions, ) { - const Wrapper: React.FunctionComponent = ({children}) => { + const Wrapper: React.FunctionComponent<{children?: React.ReactNode}> = ({ + children, + }) => { return
{children}
} return pure.render(ui, {wrapper: Wrapper, ...options}) } +export function wrappedRenderC( + ui: React.ReactElement, + options?: pure.RenderOptions, +) { + interface AppWrapperProps { + userProviderProps?: {user: string} + } + const AppWrapperProps: React.FunctionComponent = ({ + children, + userProviderProps = {user: 'TypeScript'}, + }) => { + return
{children}
+ } + + return pure.render(ui, {wrapper: AppWrapperProps, ...options}) +} + /* eslint testing-library/prefer-explicit-assert: "off",