Skip to content

Commit

Permalink
fix(render): Don't reject wrapper types based on statics (#973)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Oct 3, 2021
1 parent cde904c commit 7f53b56
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion types/index.d.ts
Expand Up @@ -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<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
Expand Down
21 changes: 20 additions & 1 deletion types/test.tsx
Expand Up @@ -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 <div>{children}</div>
}

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<AppWrapperProps> = ({
children,
userProviderProps = {user: 'TypeScript'},
}) => {
return <div data-testid={userProviderProps.user}>{children}</div>
}

return pure.render(ui, {wrapper: AppWrapperProps, ...options})
}

/*
eslint
testing-library/prefer-explicit-assert: "off",
Expand Down

0 comments on commit 7f53b56

Please sign in to comment.