From 23d498ff4665e108ce8194786564806b8399e069 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Fri, 24 Sep 2021 13:54:54 -0600 Subject: [PATCH 1/6] fix(TS): make wrapper allow a simple function comp --- types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index 663e6280..3cd9ea39 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 + wrapper?: React.ComponentType | (props: {children: React.ReactNode}) => JSX.Element } type Omit = Pick> From 064f26fd28561187e493852f33dc5b06330757dc Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Fri, 24 Sep 2021 14:00:52 -0600 Subject: [PATCH 2/6] chore: fix TS syntax --- types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index 3cd9ea39..ddcee92a 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 | (props: {children: React.ReactNode}) => JSX.Element + wrapper?: React.ComponentType | ((props: {children: React.ReactNode}) => JSX.Element) } type Omit = Pick> From 2010eb1de753e8325e8397e8beb627cba1fa1da8 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Fri, 24 Sep 2021 14:09:25 -0600 Subject: [PATCH 3/6] chore: format with prettier --- types/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index ddcee92a..65319eda 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -70,7 +70,9 @@ export interface RenderOptions< * * @see https://testing-library.com/docs/react-testing-library/api/#wrapper */ - wrapper?: React.ComponentType | ((props: {children: React.ReactNode}) => JSX.Element) + wrapper?: + | React.ComponentType + | ((props: {children: React.ReactNode}) => JSX.Element) } type Omit = Pick> From ffa222170ab0f4654319e611b5f48fce8590ddbf Mon Sep 17 00:00:00 2001 From: eps1lon Date: Mon, 27 Sep 2021 11:37:00 +0200 Subject: [PATCH 4/6] Test linked issue --- types/test.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/types/test.tsx b/types/test.tsx index 239caed6..29f8ffb2 100644 --- a/types/test.tsx +++ b/types/test.tsx @@ -100,6 +100,17 @@ export function testQueries() { ) } +export function wrappedRender( + ui: React.ReactElement, + options?: pure.RenderOptions, +) { + const Wrapper = ({children}: {children: React.ReactElement}): JSX.Element => { + return
{children}
+ } + + return pure.render(ui, {wrapper: Wrapper, ...options}) +} + /* eslint testing-library/prefer-explicit-assert: "off", From dc03098550817b9e222473c97fdc40773847c05f Mon Sep 17 00:00:00 2001 From: eps1lon Date: Mon, 27 Sep 2021 11:38:02 +0200 Subject: [PATCH 5/6] Fix type-test --- types/index.d.ts | 5 ++--- types/test.tsx | 11 +++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 65319eda..df5998be 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -6,6 +6,7 @@ import { BoundFunction, prettyFormat, } from '@testing-library/dom' +import React from 'react' import {Renderer} from 'react-dom' import {act as reactAct} from 'react-dom/test-utils' @@ -70,9 +71,7 @@ export interface RenderOptions< * * @see https://testing-library.com/docs/react-testing-library/api/#wrapper */ - wrapper?: - | React.ComponentType - | ((props: {children: React.ReactNode}) => JSX.Element) + wrapper?: React.ComponentType<{children: React.ReactElement}> } type Omit = Pick> diff --git a/types/test.tsx b/types/test.tsx index 29f8ffb2..7c45eaae 100644 --- a/types/test.tsx +++ b/types/test.tsx @@ -111,6 +111,17 @@ export function wrappedRender( return pure.render(ui, {wrapper: Wrapper, ...options}) } +export function wrappedRenderB( + ui: React.ReactElement, + options?: pure.RenderOptions, +) { + const Wrapper: React.FunctionComponent = ({children}) => { + return
{children}
+ } + + return pure.render(ui, {wrapper: Wrapper, ...options}) +} + /* eslint testing-library/prefer-explicit-assert: "off", From f23919d2e8846b0ddaffe0ac1dc339cbad152de6 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Mon, 27 Sep 2021 11:40:46 +0200 Subject: [PATCH 6/6] git hygene --- types/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index df5998be..3baf7b5e 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -6,7 +6,6 @@ import { BoundFunction, prettyFormat, } from '@testing-library/dom' -import React from 'react' import {Renderer} from 'react-dom' import {act as reactAct} from 'react-dom/test-utils'