-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more element tests, and virtual roles
- Loading branch information
1 parent
8d457cc
commit c2009d5
Showing
22 changed files
with
405 additions
and
15 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
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
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,20 @@ | ||
import { render } from '@testing-library/react'; | ||
import { byRole } from '..'; | ||
|
||
describe('audio', () => { | ||
it('renders correct structure', () => { | ||
const { container } = render( | ||
<aside> | ||
<p>The Rough-skinned Newt defends itself with a deadly neurotoxin.</p> | ||
</aside> | ||
); | ||
|
||
expect(container.firstChild).toHaveA11yTree( | ||
byRole('complementary', [ | ||
byRole('paragraph', [ | ||
'The Rough-skinned Newt defends itself with a deadly neurotoxin.', | ||
]), | ||
]) | ||
); | ||
}); | ||
}); |
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,22 @@ | ||
import { render } from '@testing-library/react'; | ||
import { byRole } from '..'; | ||
|
||
describe('abbr', () => { | ||
it('renders correct structure', () => { | ||
const { container } = render( | ||
<figure> | ||
<figcaption>Listen to the T-Rex:</figcaption> | ||
<audio controls src="/media/cc0-audio/t-rex-roar.mp3"> | ||
<a href="/media/cc0-audio/t-rex-roar.mp3">Download audio</a> | ||
</audio> | ||
</figure> | ||
); | ||
|
||
expect(container.firstChild).toHaveA11yTree( | ||
byRole('figure', [ | ||
byRole('Figcaption', ['Listen to the T-Rex:']), | ||
byRole('Audio', [byRole('link', ['Download audio'])]), | ||
]) | ||
); | ||
}); | ||
}); |
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,25 @@ | ||
import { render } from '@testing-library/react'; | ||
import { byRole } from '..'; | ||
|
||
describe('abbr', () => { | ||
it('renders correct structure', () => { | ||
const { container } = render( | ||
<p> | ||
The two most popular science courses offered by the school are | ||
<b>chemistry</b> (the study of chemicals and the composition of | ||
substances) and <strong>physics</strong> (the study of the nature and | ||
properties of matter and energy). | ||
</p> | ||
); | ||
|
||
expect(container.firstChild).toHaveA11yTree( | ||
byRole('paragraph', [ | ||
'The two most popular science courses offered by the school are', | ||
'chemistry', | ||
' (the study of chemicals and the composition of substances) and ', | ||
byRole('strong', ['physics']), | ||
' (the study of the nature and properties of matter and energy).', | ||
]) | ||
); | ||
}); | ||
}); |
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,17 @@ | ||
import { render } from '@testing-library/react'; | ||
import { byRole } from '..'; | ||
|
||
describe('abbr', () => { | ||
it('renders correct structure', () => { | ||
const { container } = render( | ||
<p> | ||
<bdi>Evil Steven</bdi> | ||
<bdo dir="ltr">אה, אני אוהב להיות ליד חוף הים</bdo> | ||
</p> | ||
); | ||
|
||
expect(container.firstChild).toHaveA11yTree( | ||
byRole('paragraph', ['Evil Steven', 'אה, אני אוהב להיות ליד חוף הים']) | ||
); | ||
}); | ||
}); |
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,27 @@ | ||
import { render } from '@testing-library/react'; | ||
import { byRole } from '..'; | ||
|
||
describe('blockquote', () => { | ||
it('renders correct structure', () => { | ||
const { container } = render( | ||
<blockquote cite="https://www.huxley.net/bnw/four.html"> | ||
<p> | ||
Words can be like X-rays, if you use them properly—they’ll go through | ||
anything. You read and you’re pierced. | ||
</p> | ||
<footer> | ||
—Aldous Huxley, <cite>Brave New World</cite> | ||
</footer> | ||
</blockquote> | ||
); | ||
|
||
expect(container.firstChild).toHaveA11yTree( | ||
byRole('blockquote', [ | ||
byRole('paragraph', [ | ||
'Words can be like X-rays, if you use them properly—they’ll go through anything. You read and you’re pierced.', | ||
]), | ||
byRole('contentinfo', ['—Aldous Huxley, ', 'Brave New World']), | ||
]) | ||
); | ||
}); | ||
}); |
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,22 @@ | ||
import { render } from '@testing-library/react'; | ||
import { byRole } from '..'; | ||
|
||
describe('br', () => { | ||
it('renders correct structure', () => { | ||
const { container } = render( | ||
<p> | ||
O’er all the hilltops | ||
<br /> | ||
Is quiet now, | ||
</p> | ||
); | ||
|
||
expect(container.firstChild).toHaveA11yTree( | ||
byRole('paragraph', [ | ||
'O’er all the hilltops', | ||
byRole('LineBreak'), | ||
'Is quiet now,', | ||
]) | ||
); | ||
}); | ||
}); |
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,14 @@ | ||
import { render } from '@testing-library/react'; | ||
import { byRole } from '..'; | ||
|
||
describe('button', () => { | ||
it('renders correct structure', () => { | ||
const { container } = render( | ||
<button type="button">Add to favorites</button> | ||
); | ||
|
||
expect(container.firstChild).toHaveA11yTree( | ||
byRole('button', ['Add to favorites']) | ||
); | ||
}); | ||
}); |
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,18 @@ | ||
import { render } from '@testing-library/react'; | ||
import { byRole } from '..'; | ||
|
||
describe('a', () => { | ||
it('renders correct structure', () => { | ||
const { container } = render( | ||
<canvas width="120" height="120"> | ||
An alternative text describing what your canvas displays. | ||
</canvas> | ||
); | ||
|
||
expect(container.firstChild).toHaveA11yTree( | ||
byRole('Canvas', [ | ||
'An alternative text describing what your canvas displays.', | ||
]) | ||
); | ||
}); | ||
}); |
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,42 @@ | ||
import { render } from '@testing-library/react'; | ||
import { byRole } from '..'; | ||
|
||
describe('caption', () => { | ||
it('renders correct structure', () => { | ||
const { container } = render( | ||
<table> | ||
<caption>He-Man and Skeletor facts</caption> | ||
<tbody> | ||
<tr> | ||
<td> </td> | ||
<th scope="col">He-Man</th> | ||
<th scope="col">Skeletor</th> | ||
</tr> | ||
<tr> | ||
<th scope="row">Role</th> | ||
<td>Hero</td> | ||
<td>Villain</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
); | ||
|
||
expect(container.firstChild).toHaveA11yTree( | ||
byRole('table', [ | ||
byRole('caption', ['He-Man and Skeletor facts']), | ||
byRole('rowgroup', [ | ||
byRole('row', [ | ||
byRole('cell', [' ']), | ||
byRole('columnheader', 'He-Man'), | ||
byRole('columnheader', 'Skeletor'), | ||
]), | ||
byRole('row', [ | ||
byRole('rowheader', 'Role'), | ||
byRole('cell', 'Hero'), | ||
byRole('cell', 'Villain'), | ||
]), | ||
]), | ||
]) | ||
); | ||
}); | ||
}); |
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,21 @@ | ||
import { render } from '@testing-library/react'; | ||
import { byRole } from '..'; | ||
|
||
describe('', () => { | ||
it('renders correct structure', () => { | ||
const { container } = render( | ||
<p> | ||
The <code>push()</code> method adds one or more elements to the end of | ||
an array and returns the new length of the array. | ||
</p> | ||
); | ||
|
||
expect(container.firstChild).toHaveA11yTree( | ||
byRole('paragraph', [ | ||
'The ', | ||
byRole('code', ['push()']), | ||
' method adds one or more elements to the end of an array and returns the new length of the array.', | ||
]) | ||
); | ||
}); | ||
}); |
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,55 @@ | ||
import { render } from '@testing-library/react'; | ||
import { byRole } from '..'; | ||
|
||
describe('', () => { | ||
it('renders correct structure', () => { | ||
const { container } = render( | ||
<table> | ||
<caption>Superheros and sidekicks</caption> | ||
<colgroup> | ||
<col /> | ||
<col span={2} /> | ||
<col span={2} /> | ||
</colgroup> | ||
<tbody> | ||
<tr> | ||
<td></td> | ||
<th scope="col">Batman</th> | ||
<th scope="col">Robin</th> | ||
<th scope="col">The Flash</th> | ||
<th scope="col">Kid Flash</th> | ||
</tr> | ||
<tr> | ||
<th scope="row">Skill</th> | ||
<td>Smarts</td> | ||
<td>Dex, acrobat</td> | ||
<td>Super speed</td> | ||
<td>Super speed</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
); | ||
|
||
expect(container.firstChild).toHaveA11yTree( | ||
byRole('table', [ | ||
byRole('caption', ['Superheros and sidekicks']), | ||
byRole('rowgroup', [ | ||
byRole('row', [ | ||
byRole('cell'), | ||
byRole('columnheader', ['Batman']), | ||
byRole('columnheader', ['Robin']), | ||
byRole('columnheader', ['The Flash']), | ||
byRole('columnheader', ['Kid Flash']), | ||
]), | ||
byRole('row', [ | ||
byRole('rowheader', ['Skill']), | ||
byRole('cell', ['Smarts']), | ||
byRole('cell', ['Dex, acrobat']), | ||
byRole('cell', ['Super speed']), | ||
byRole('cell', ['Super speed']), | ||
]), | ||
]), | ||
]) | ||
); | ||
}); | ||
}); |
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,34 @@ | ||
import { render } from '@testing-library/react'; | ||
import { byRole } from '..'; | ||
|
||
describe('', () => { | ||
it('renders correct structure', () => { | ||
const { container } = render( | ||
<> | ||
<p>New Products:</p> | ||
<ul> | ||
<li> | ||
<data value="398">Mini Ketchup</data> | ||
</li> | ||
<li> | ||
<data value="399">Jumbo Ketchup</data> | ||
</li> | ||
<li> | ||
<data value="400">Mega Jumbo Ketchup</data> | ||
</li> | ||
</ul> | ||
</> | ||
); | ||
|
||
expect(container).toHaveA11yTree( | ||
byRole('generic', [ | ||
byRole('paragraph', ['New Products:']), | ||
byRole('list', [ | ||
byRole('listitem', ['Mini Ketchup']), | ||
byRole('listitem', ['Jumbo Ketchup']), | ||
byRole('listitem', ['Mega Jumbo Ketchup']), | ||
]), | ||
]) | ||
); | ||
}); | ||
}); |
Oops, something went wrong.