|
| 1 | +import { render } from '@testing-library/react'; |
| 2 | +import { byRole } from '..'; |
| 3 | + |
| 4 | +describe('map-area', () => { |
| 5 | + it('renders correct structure', () => { |
| 6 | + const { container } = render( |
| 7 | + <> |
| 8 | + <map name="infographic"> |
| 9 | + <area |
| 10 | + shape="poly" |
| 11 | + coords="129,0,260,95,129,138" |
| 12 | + href="https://developer.mozilla.org/docs/Web/HTTP" |
| 13 | + target="_blank" |
| 14 | + alt="HTTP" |
| 15 | + /> |
| 16 | + <area |
| 17 | + shape="poly" |
| 18 | + coords="260,96,209,249,130,138" |
| 19 | + href="https://developer.mozilla.org/docs/Web/HTML" |
| 20 | + target="_blank" |
| 21 | + alt="HTML" |
| 22 | + /> |
| 23 | + <area |
| 24 | + shape="poly" |
| 25 | + coords="209,249,49,249,130,139" |
| 26 | + href="https://developer.mozilla.org/docs/Web/JavaScript" |
| 27 | + target="_blank" |
| 28 | + alt="JavaScript" |
| 29 | + /> |
| 30 | + <area |
| 31 | + shape="poly" |
| 32 | + coords="48,249,0,96,129,138" |
| 33 | + href="https://developer.mozilla.org/docs/Web/API" |
| 34 | + target="_blank" |
| 35 | + alt="Web APIs" |
| 36 | + /> |
| 37 | + <area |
| 38 | + shape="poly" |
| 39 | + coords="0,95,128,0,128,137" |
| 40 | + href="https://developer.mozilla.org/docs/Web/CSS" |
| 41 | + target="_blank" |
| 42 | + alt="CSS" |
| 43 | + /> |
| 44 | + </map> |
| 45 | + <img |
| 46 | + useMap="#infographic" |
| 47 | + src="/media/examples/mdn-info.png" |
| 48 | + alt="MDN infographic" |
| 49 | + /> |
| 50 | + </> |
| 51 | + ); |
| 52 | + |
| 53 | + expect(container).toHaveA11yTree( |
| 54 | + byRole('generic', [ |
| 55 | + byRole(undefined, [ |
| 56 | + byRole('link', 'HTTP'), |
| 57 | + byRole('link', 'HTML'), |
| 58 | + byRole('link', 'JavaScript'), |
| 59 | + byRole('link', 'Web APIs'), |
| 60 | + byRole('link', 'CSS'), |
| 61 | + ]), |
| 62 | + byRole('img', 'MDN infographic'), |
| 63 | + ]) |
| 64 | + ); |
| 65 | + }); |
| 66 | +}); |
0 commit comments