Skip to content

Commit

Permalink
test(sbb-screen-reader-only): add visual tests (#2868)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideMininni-Fincons authored Jul 1, 2024
1 parent 848bd83 commit 128ce53
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* @web/test-runner snapshot v1 */
export const snapshots = {};

snapshots["sbb-screen-reader-only renders with Light DOM"] =
snapshots["sbb-screen-reader-only renders DOM"] =
`<sbb-screen-reader-only>
</sbb-screen-reader-only>
`;
/* end snapshot sbb-screen-reader-only renders with Light DOM */
/* end snapshot sbb-screen-reader-only renders DOM */

snapshots["sbb-screen-reader-only renders with Shadow DOM"] =
snapshots["sbb-screen-reader-only renders Shadow DOM"] =
`<slot>
</slot>
`;
/* end snapshot sbb-screen-reader-only renders with Shadow DOM */
/* end snapshot sbb-screen-reader-only renders Shadow DOM */

snapshots["sbb-screen-reader-only renders A11y tree Chrome"] =
`<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ describe(`sbb-screen-reader-only`, () => {
root = await fixture(html`<sbb-screen-reader-only></sbb-screen-reader-only>`);
});

it('with Light DOM', async () => {
it('DOM', async () => {
await expect(root).dom.to.be.equalSnapshot();
});

it('with Shadow DOM', async () => {
it('Shadow DOM', async () => {
await expect(root).shadowDom.to.be.equalSnapshot();
});

Expand Down
21 changes: 21 additions & 0 deletions src/elements/screen-reader-only/screen-reader-only.visual.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { html } from 'lit';

import { describeViewports, visualDiffDefault } from '../core/testing/private.js';

import './screen-reader-only.js';

describe(`sbb-screen-reader-only`, () => {
describeViewports({ viewports: ['medium'] }, () => {
it(
visualDiffDefault.name,
visualDiffDefault.with(async (setup) => {
await setup.withFixture(html`
There is a visually hidden text here:
<sbb-screen-reader-only>
I'm visually hidden, but read to screen reader.
</sbb-screen-reader-only>
`);
}),
);
});
});

0 comments on commit 128ce53

Please sign in to comment.