From e057e9cf65a870670cf81b319f5c3b48a73b44aa Mon Sep 17 00:00:00 2001
From: Connor Meredith <4907463+connormeredith@users.noreply.github.com>
Date: Tue, 19 Nov 2019 08:35:38 +0000
Subject: [PATCH] Added jest matcher support for .toHaveValue()
---
README.md | 17 +++++++-----
extend-expect.d.ts | 2 +-
src/__tests__/to-have-value.js | 48 ++++++++++++++++++++++++++++++----
src/to-have-value.js | 10 ++-----
4 files changed, 56 insertions(+), 21 deletions(-)
diff --git a/README.md b/README.md
index 166bfa4c..6f4fc9f6 100644
--- a/README.md
+++ b/README.md
@@ -46,6 +46,7 @@ clear to read and to maintain.
+
- [Installation](#installation)
- [Usage](#usage)
- [Custom matchers](#custom-matchers)
@@ -86,9 +87,10 @@ should be installed as one of your project's `devDependencies`:
npm install --save-dev @testing-library/jest-dom
```
-> Note: We also recommend installing the jest-dom eslint plugin which provides auto-fixable lint rules
-> that prevent false positive tests and improve test readability by ensuring you are using the right
-> matchers in your tests. More details can be found at
+> Note: We also recommend installing the jest-dom eslint plugin which provides
+> auto-fixable lint rules that prevent false positive tests and improve test
+> readability by ensuring you are using the right matchers in your tests. More
+> details can be found at
> [eslint-plugin-jest-dom](https://github.com/testing-library/eslint-plugin-jest-dom).
## Usage
@@ -610,7 +612,7 @@ toHaveAttribute(attr: string, value?: any)
This allows you to check whether the given element has an attribute or not. You
can also optionally check that the attribute has a specific expected value or
partial match using
-[expect.stringContaining](https://jestjs.io/docs/en/expect.html#expectnotstringcontainingstring)/[expect.stringMatching](https://jestjs.io/docs/en/expect.html#expectstringmatchingstring-regexp)
+[expect.stringContaining](https://jestjs.io/docs/en/expect.html#expectstringcontainingstring)/[expect.stringMatching](https://jestjs.io/docs/en/expect.html#expectstringmatchingstring-regexp).
#### Examples
@@ -922,10 +924,12 @@ expect(element).not.toHaveTextContent('content')
### `toHaveValue`
```typescript
-toHaveValue(value: string | string[] | number)
+toHaveValue(value?: any)
```
-This allows you to check whether the given form element has the specified value.
+This allows you to check whether the given form element has the specified value
+or partial value using
+[expect.stringContaining](https://jestjs.io/docs/en/expect.html#expectstringcontainingstring)/[expect.stringMatching](https://jestjs.io/docs/en/expect.html#expectstringmatchingstring-regexp).
It accepts ``, `