From 5d89901408001bb3b70b328d15325f1b763588c0 Mon Sep 17 00:00:00 2001 From: Brent Erickson Date: Thu, 30 Apr 2020 09:56:49 -0700 Subject: [PATCH 1/6] [@testing-library/jest-dom] Add types for toHaveDisplayValue --- types/testing-library__jest-dom/index.d.ts | 51 ++++++++++++++++++- .../testing-library__jest-dom-global-tests.ts | 6 +++ 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/types/testing-library__jest-dom/index.d.ts b/types/testing-library__jest-dom/index.d.ts index ba09a068368632..c35162956c8d5e 100644 --- a/types/testing-library__jest-dom/index.d.ts +++ b/types/testing-library__jest-dom/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for @testing-library/jest-dom 5.6 +// Type definitions for @testing-library/jest-dom 5.7 // Project: https://github.com/testing-library/jest-dom // Definitions by: Ernesto García // John Gozde @@ -253,7 +253,54 @@ declare namespace jest { toHaveClass(...classNames: string[]): R; /** * @description - * Assert whether an element has focus or not. + * Check whether the given form element has the specified value. + * + * Accepts ``, ` + * + * + * + * + * + * + * + * const input = screen.getByLabelText('First name') + * const textarea = screen.getByLabelText('Description') + * const selectSingle = screen.getByLabelText('Fruit') + * const selectMultiple = screen.getByLabelText('Fruits') + * + * expect(input).toHaveDisplayValue('Luca') + * expect(textarea).toHaveDisplayValue('An example description here.') + * expect(selectSingle).toHaveDisplayValue('Select a fruit...') + * expect(selectMultiple).toHaveDisplayValue(['Banana', 'Avocado']) + * + * @see + * [testing-library/jest-dom#tohavedisplayvalue](https:github.com/testing-library/jest-dom#tohavedisplayvalue) + */ + toHaveDisplayValue(value?: string | string[]): R; + /** + * @description + * This allows you to check whether the given form element has the specified displayed value (the one the + * end user will see). It accepts ,