@testing-library/jest-dom
Advanced tools
Comparing version 5.7.0 to 5.8.0
@@ -126,2 +126,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "toBePartiallyChecked", { | ||
enumerable: true, | ||
get: function () { | ||
return _toBePartiallyChecked.toBePartiallyChecked; | ||
} | ||
}); | ||
Object.defineProperty(exports, "toHaveDescription", { | ||
@@ -170,2 +176,4 @@ enumerable: true, | ||
var _toBePartiallyChecked = require("./to-be-partially-checked"); | ||
var _toHaveDescription = require("./to-have-description"); |
{ | ||
"name": "@testing-library/jest-dom", | ||
"version": "5.7.0", | ||
"version": "5.8.0", | ||
"description": "Custom jest matchers to test the state of the DOM", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -49,3 +49,2 @@ <div align="center"> | ||
- [Installation](#installation) | ||
@@ -73,2 +72,3 @@ - [Usage](#usage) | ||
- [`toBeChecked`](#tobechecked) | ||
- [`toBePartiallyChecked`](#tobepartiallychecked) | ||
- [`toHaveDescription`](#tohavedescription) | ||
@@ -900,2 +900,48 @@ - [Deprecated matchers](#deprecated-matchers) | ||
### `toBePartiallyChecked` | ||
```typescript | ||
toBePartiallyChecked() | ||
``` | ||
This allows you to check whether the given element is partially checked. It | ||
accepts an `input` of type `checkbox` and elements with a `role` of `checkbox` | ||
with a `aria-checked="mixed"`, or `input` of type `checkbox` with | ||
`indeterminate` set to `true` | ||
#### Examples | ||
```html | ||
<input type="checkbox" aria-checked="mixed" data-testid="aria-checkbox-mixed" /> | ||
<input type="checkbox" checked data-testid="input-checkbox-checked" /> | ||
<input type="checkbox" data-testid="input-checkbox-unchecked" /> | ||
<div role="checkbox" aria-checked="true" data-testid="aria-checkbox-checked" /> | ||
<div | ||
role="checkbox" | ||
aria-checked="false" | ||
data-testid="aria-checkbox-unchecked" | ||
/> | ||
<input type="checkbox" data-testid="input-checkbox-indeterminate" /> | ||
``` | ||
```javascript | ||
const ariaCheckboxMixed = getByTestId('aria-checkbox-mixed') | ||
const inputCheckboxChecked = getByTestId('input-checkbox-checked') | ||
const inputCheckboxUnchecked = getByTestId('input-checkbox-unchecked') | ||
const ariaCheckboxChecked = getByTestId('aria-checkbox-checked') | ||
const ariaCheckboxUnchecked = getByTestId('aria-checkbox-unchecked') | ||
const inputCheckboxIndeterminate = getByTestId('input-checkbox-indeterminate') | ||
expect(ariaCheckboxMixed).toBePartiallyChecked() | ||
expect(inputCheckboxChecked).not.toBePartiallyChecked() | ||
expect(inputCheckboxUnchecked).not.toBePartiallyChecked() | ||
expect(ariaCheckboxChecked).not.toBePartiallyChecked() | ||
expect(ariaCheckboxUnchecked).not.toBePartiallyChecked() | ||
inputCheckboxIndeterminate.indeterminate = true | ||
expect(inputCheckboxIndeterminate).toBePartiallyChecked() | ||
``` | ||
<hr /> | ||
### `toHaveDescription` | ||
@@ -902,0 +948,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98498
30
974
1188