diff --git a/examples/typescript/src/__snapshots__/index.test.ts.snap b/examples/typescript/src/__snapshots__/matchers.test.ts.snap similarity index 100% rename from examples/typescript/src/__snapshots__/index.test.ts.snap rename to examples/typescript/src/__snapshots__/matchers.test.ts.snap diff --git a/examples/typescript/src/__snapshots__/mix.test.ts.snap b/examples/typescript/src/__snapshots__/mix.test.ts.snap new file mode 100644 index 0000000..dc0e771 --- /dev/null +++ b/examples/typescript/src/__snapshots__/mix.test.ts.snap @@ -0,0 +1,47 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`matchers snapshot tests toMatchScreenReaderSnapshot on the whole body: toMatchScreenReaderSnapshot 1`] = ` +[ + "document", + "navigation", + "Nav Text", + "end of navigation", + "region", + "heading, First Section Heading, level 1", + "paragraph", + "First Section Text", + "end of paragraph", + "article", + "banner", + "heading, Article Header Heading, level 1", + "paragraph", + "Article Header Text", + "end of paragraph", + "end of banner", + "paragraph", + "Article Text", + "end of paragraph", + "end of article", + "end of region", + "region", + "heading, Second Section Heading, level 1", + "paragraph", + "Second Section Text", + "end of paragraph", + "end of region", + "contentinfo", + "Footer", + "end of contentinfo", + "end of document", +] +`; + +exports[`matchers virtual screen reader tests navigating headings 1`] = ` +[ + "document", + "heading, First Section Heading, level 1", + "heading, Article Header Heading, level 1", + "heading, Second Section Heading, level 1", + "heading, First Section Heading, level 1", +] +`; diff --git a/examples/typescript/src/index.test.ts b/examples/typescript/src/matchers.test.ts similarity index 100% rename from examples/typescript/src/index.test.ts rename to examples/typescript/src/matchers.test.ts diff --git a/examples/typescript/src/mix.test.ts b/examples/typescript/src/mix.test.ts new file mode 100644 index 0000000..50f64d0 --- /dev/null +++ b/examples/typescript/src/mix.test.ts @@ -0,0 +1,60 @@ +import { virtual } from "@guidepup/virtual-screen-reader"; + +function setupBasicPage() { + document.body.innerHTML = ` + +
+

First Section Heading

+

First Section Text

+
+
+

Article Header Heading

+

Article Header Text

+
+

Article Text

+
+
+
+

Second Section Heading

+

Second Section Text

+
+ + + `; +} + +describe("matchers", () => { + beforeEach(() => { + setupBasicPage(); + }); + + afterEach(() => { + document.body.innerHTML = ``; + }); + + describe("snapshot tests", () => { + test("toMatchScreenReaderSnapshot on the whole body", async () => { + await expect(document.body).toMatchScreenReaderSnapshot(); + }); + }); + + describe("virtual screen reader tests", () => { + test("navigating headings", async () => { + await virtual.start({ container: document.body }); + + await virtual.perform(virtual.commands.moveToNextHeading); + const firstHeadingPhrase = await virtual.lastSpokenPhrase(); + + do { + await virtual.perform(virtual.commands.moveToNextHeading); + } while ((await virtual.lastSpokenPhrase()) !== firstHeadingPhrase); + + expect(await virtual.spokenPhraseLog()).toMatchSnapshot(); + + await virtual.stop(); + }); + }); +});