-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dependency @testing-library/jest-dom to v5.14.1 (#104)
Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Caleb Eby <caleb.eby01@gmail.com>
- Loading branch information
1 parent
0e65178
commit 69fd00b
Showing
9 changed files
with
180 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'pleasantest': minor | ||
--- | ||
|
||
Remove toHaveDescription, toBeInTheDOM, and toBeEmpty (they are deprecated by jest-dom) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'pleasantest': minor | ||
--- | ||
|
||
Add toHaveAccessibleDescription and toHaveAccessibleName from jest-dom matchers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
tests/jest-dom-matchers/toHaveAccessibleDescription.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { withBrowser } from 'pleasantest'; | ||
|
||
test( | ||
'toHaveAccessibleDescription', | ||
withBrowser(async ({ screen, utils }) => { | ||
await utils.injectHTML(` | ||
<a | ||
data-testid="link" | ||
href="/" | ||
aria-label="Home page" | ||
title="A link to start over" | ||
>Start</a | ||
> | ||
<a data-testid="extra-link" href="/about" aria-label="About page">About</a> | ||
<img src="" data-testid="avatar" alt="User profile pic" /> | ||
<img | ||
src="" | ||
data-testid="logo" | ||
alt="Company logo" | ||
aria-describedby="t1" | ||
/> | ||
<span id="t1" role="presentation">The logo of Our Company</span> | ||
`); | ||
|
||
const link = await screen.getByTestId('link'); | ||
await expect(link).toHaveAccessibleDescription(); | ||
await expect(expect(link).not.toHaveAccessibleDescription()).rejects | ||
.toThrowErrorMatchingInlineSnapshot(` | ||
"[2mexpect([22m[31melement[39m[2m).not.toHaveAccessibleDescription()[22m | ||
Expected element not to have accessible description: | ||
[32m null[39m | ||
Received: | ||
[31m A link to start over[39m" | ||
`); | ||
await expect(link).toHaveAccessibleDescription('A link to start over'); | ||
await expect(link).not.toHaveAccessibleDescription('Home page'); | ||
await expect(expect(link).toHaveAccessibleDescription('Home page')).rejects | ||
.toThrowErrorMatchingInlineSnapshot(` | ||
"[2mexpect([22m[31melement[39m[2m).toHaveAccessibleDescription()[22m | ||
Expected element to have accessible description: | ||
[32m Home page[39m | ||
Received: | ||
[31m A link to start over[39m" | ||
`); | ||
|
||
await expect( | ||
await screen.getByTestId('extra-link'), | ||
).not.toHaveAccessibleDescription(); | ||
|
||
await expect( | ||
await screen.getByTestId('avatar'), | ||
).not.toHaveAccessibleDescription(); | ||
|
||
const logo = await screen.getByTestId('logo'); | ||
await expect(logo).not.toHaveAccessibleDescription('Company logo'); | ||
await expect(logo).toHaveAccessibleDescription('The logo of Our Company'); | ||
}), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { withBrowser } from 'pleasantest'; | ||
|
||
test( | ||
'toHaveAccessibleName', | ||
withBrowser(async ({ screen, utils }) => { | ||
await utils.injectHTML(` | ||
<img data-testid="img-alt" src="" alt="Test alt" /> | ||
<img data-testid="img-empty-alt" src="" alt="" /> | ||
<svg data-testid="svg-title"><title>Test title</title></svg> | ||
<button data-testid="button-img-alt"><img src="" alt="Test" /></button> | ||
<p><img data-testid="img-paragraph" src="" alt="" /> Test content</p> | ||
<button data-testid="svg-button"><svg><title>Test</title></svg></p> | ||
<div><svg data-testid="svg-without-title"></svg></div> | ||
<input data-testid="input-title" title="test" /> | ||
`); | ||
|
||
await expect(await screen.getByTestId('img-alt')).toHaveAccessibleName( | ||
'Test alt', | ||
); | ||
|
||
await expect(await screen.getByTestId('img-alt')).not.toHaveAccessibleName( | ||
'not test alt', | ||
); | ||
await expect( | ||
expect(await screen.getByTestId('img-alt')).toHaveAccessibleName( | ||
'not test alt', | ||
), | ||
).rejects.toThrowErrorMatchingInlineSnapshot(` | ||
"[2mexpect([22m[31melement[39m[2m).toHaveAccessibleName()[22m | ||
Expected element to have accessible name: | ||
[32m not test alt[39m | ||
Received: | ||
[31m Test alt[39m" | ||
`); | ||
|
||
await expect( | ||
expect(await screen.getByTestId('img-empty-alt')).toHaveAccessibleName(), | ||
).rejects.toThrowErrorMatchingInlineSnapshot(` | ||
"[2mexpect([22m[31melement[39m[2m).toHaveAccessibleName()[22m | ||
Expected element to have accessible name: | ||
[32m null[39m | ||
Received: | ||
" | ||
`); | ||
|
||
await expect( | ||
await screen.getByTestId('img-empty-alt'), | ||
).not.toHaveAccessibleName(); | ||
await expect( | ||
expect(await screen.getByTestId('img-empty-alt')).toHaveAccessibleName(), | ||
).rejects.toThrowErrorMatchingInlineSnapshot(` | ||
"[2mexpect([22m[31melement[39m[2m).toHaveAccessibleName()[22m | ||
Expected element to have accessible name: | ||
[32m null[39m | ||
Received: | ||
" | ||
`); | ||
|
||
await expect(await screen.getByTestId('svg-title')).toHaveAccessibleName( | ||
'Test title', | ||
); | ||
|
||
await expect( | ||
await screen.getByTestId('button-img-alt'), | ||
).toHaveAccessibleName(); | ||
|
||
await expect( | ||
await screen.getByTestId('img-paragraph'), | ||
).not.toHaveAccessibleName(); | ||
|
||
await expect(await screen.getByTestId('svg-button')).toHaveAccessibleName(); | ||
|
||
await expect( | ||
await screen.getByTestId('svg-without-title'), | ||
).not.toHaveAccessibleName(); | ||
|
||
await expect( | ||
await screen.getByTestId('input-title'), | ||
).toHaveAccessibleName(); | ||
}), | ||
); |
This file was deleted.
Oops, something went wrong.