Skip to content

Instantly share code, notes, and snippets.

@craigcarlyle
Created August 3, 2018 18:46
Show Gist options
  • Save craigcarlyle/a84dff319691caf53d480e9c2c339d87 to your computer and use it in GitHub Desktop.
Save craigcarlyle/a84dff319691caf53d480e9c2c339d87 to your computer and use it in GitHub Desktop.
a11y KeyDown Usage
describe("Keyboard Interactions", () => {
describe("when checkbox has focus and the 'Space' key is pressed", () => {
describe("while unchecked", () => {
it("checks the checkbox", () => {
cy.keyDown("#axe-test #basic.th-checkbox", "Space");
cy.get("#axe-test #basic.th-checkbox").should("have.attr", "aria-checked", "true");
});
});
describe("while checked", () => {
it("unchecks the checkbox", () => {
cy.keyDown("#axe-test #basic.th-checkbox", "Space");
cy.keyDown("#axe-test #basic.th-checkbox", "Space");
cy.get("#axe-test #basic.th-checkbox").should("have.attr", "aria-checked", "false");
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment