From aa5b9deff72c2d7eb115ed6a5c178c65c4be123a Mon Sep 17 00:00:00 2001 From: Ifiok Jr Date: Mon, 19 Aug 2019 23:05:51 +0100 Subject: [PATCH] feat: update testing-library__react (#37705) Add pure module types --- types/testing-library__react/index.d.ts | 1 + types/testing-library__react/pure.d.ts | 1 + .../testing-library__react-tests.tsx | 18 ++++++++++++++++++ types/testing-library__react/tsconfig.json | 3 ++- 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 types/testing-library__react/pure.d.ts diff --git a/types/testing-library__react/index.d.ts b/types/testing-library__react/index.d.ts index c63ea1e53a..6c7404ef0b 100644 --- a/types/testing-library__react/index.d.ts +++ b/types/testing-library__react/index.d.ts @@ -4,6 +4,7 @@ // Kent C Dodds // Sebastian Silbermann // Weyert de Boer +// Ifiok Jr. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.0 diff --git a/types/testing-library__react/pure.d.ts b/types/testing-library__react/pure.d.ts new file mode 100644 index 0000000000..b13bb4eb87 --- /dev/null +++ b/types/testing-library__react/pure.d.ts @@ -0,0 +1 @@ +export * from './'; diff --git a/types/testing-library__react/testing-library__react-tests.tsx b/types/testing-library__react/testing-library__react-tests.tsx index dd82f679f4..1b4b4849ed 100644 --- a/types/testing-library__react/testing-library__react-tests.tsx +++ b/types/testing-library__react/testing-library__react-tests.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; import { render, fireEvent } from '@testing-library/react'; +import * as pure from '@testing-library/react/pure'; async function testRender() { const page = render(
); @@ -18,6 +19,23 @@ async function testRender() { const { container, rerender, debug } = page; } +async function testPureRender() { + const page = pure.render(
); + + // single queries + page.getByText('foo'); + page.queryByText('foo'); + await page.findByText('foo'); + + // multiple queries + page.getAllByText('bar'); + page.queryAllByText('bar'); + await page.findAllByText('bar'); + + // helpers + const { container, rerender, debug } = page; +} + async function testRenderOptions() { const container = document.createElement('div'); const options = { container }; diff --git a/types/testing-library__react/tsconfig.json b/types/testing-library__react/tsconfig.json index 84b998908f..6a57478473 100644 --- a/types/testing-library__react/tsconfig.json +++ b/types/testing-library__react/tsconfig.json @@ -15,8 +15,9 @@ "forceConsistentCasingInFileNames": true, "paths": { "@testing-library/react": ["testing-library__react"], + "@testing-library/react/*": ["testing-library__react/*"], "@testing-library/dom": ["testing-library__dom"] } }, - "files": ["index.d.ts", "testing-library__react-tests.tsx"] + "files": ["index.d.ts", "pure.d.ts", "testing-library__react-tests.tsx"] }