-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial support act, press, and type
- Loading branch information
1 parent
39beeab
commit 961e393
Showing
5 changed files
with
322 additions
and
9 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@guidepup/virtual-screen-reader", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Virtual screen reader driver for unit test automation.", | ||
"main": "lib/index.js", | ||
"author": "Craig Morten <[email protected]>", | ||
|
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,65 @@ | ||
import { getByText, queryByText } from "@testing-library/dom"; | ||
import { virtual } from "../../src"; | ||
|
||
function setupButtonPage() { | ||
document.body.innerHTML = ` | ||
<p id="status">Not Clicked</p> | ||
<div id="hidden" style="display: none;">Hidden</div> | ||
`; | ||
|
||
const button = document.createElement("button"); | ||
|
||
button.addEventListener("click", function (event) { | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
document.getElementById( | ||
"status" | ||
)!.innerHTML = `Clicked ${event.detail} Time(s)`; | ||
}); | ||
|
||
button.innerHTML = "Click Me"; | ||
|
||
document.body.appendChild(button); | ||
} | ||
|
||
describe("act", () => { | ||
beforeEach(() => { | ||
setupButtonPage(); | ||
}); | ||
|
||
it("should perform the default action", async () => { | ||
const container = document.body; | ||
|
||
await virtual.start({ container }); | ||
|
||
expect(getByText(container, "Not Clicked")).toBeInTheDocument(); | ||
|
||
while ((await virtual.itemText()) !== "Click Me") { | ||
await virtual.next(); | ||
} | ||
|
||
await virtual.act(); | ||
|
||
expect(queryByText(container, "Not Clicked")).not.toBeInTheDocument(); | ||
expect(getByText(container, "Clicked 1 Time(s)")).toBeInTheDocument(); | ||
|
||
await virtual.previous(); | ||
|
||
expect(await virtual.lastSpokenPhrase()).toEqual("Clicked 1 Time(s)"); | ||
|
||
await virtual.stop(); | ||
}); | ||
|
||
it("should handle requests to perform the default action on hidden container gracefully", async () => { | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const container = document.querySelector("#hidden")! as HTMLElement; | ||
|
||
await virtual.start({ container }); | ||
|
||
await virtual.act(); | ||
|
||
expect(await virtual.itemTextLog()).toEqual([]); | ||
expect(await virtual.spokenPhraseLog()).toEqual([]); | ||
|
||
await virtual.stop(); | ||
}); | ||
}); |
Oops, something went wrong.