Skip to content

Commit

Permalink
SIA R12: Add Test (#800)
Browse files Browse the repository at this point in the history
* Pass tests for R12 implemented, starting with failed

* Update rule.spec.tsx

* Test rule 12 finished

* Apply suggestions from code review

Co-authored-by: Jean-Yves Moyen <[email protected]>

* Text sintax improved

Co-authored-by: Jean-Yves Moyen <[email protected]>
  • Loading branch information
elenamongelli and Jym77 committed Jun 17, 2021
1 parent a51e463 commit 91a8fbe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
31 changes: 15 additions & 16 deletions packages/alfa-rules/test/sia-r12/rule.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { h } from "@siteimprove/alfa-dom";
import { test } from "@siteimprove/alfa-test";

import { Document } from "@siteimprove/alfa-dom";

import R12, { Outcomes } from "../../src/sia-r12/rule";

import { evaluate } from "../common/evaluate";
import { passed, failed, inapplicable } from "../common/outcome";

test(`evaluates() passes a <button> with accessible name given by content`, async (t) => {
test(`evaluates() passes a <button> with accessible name `, async (t) => {
const target = <button>My button</button>;

const document = h.document([target]);
const document = Document.of([target]);

t.deepEqual(await evaluate(R12, { document }), [
passed(R12, target, {
Expand All @@ -18,11 +19,10 @@ test(`evaluates() passes a <button> with accessible name given by content`, asyn
]);
});

test(`evaluates() passes a submit button element with an accessible name given
by the value attribute `, async (t) => {
test(`evaluates() passes a submit button element with an accessible name given by the value attribute `, async (t) => {
const input = <input type="submit" value="Submit" />;

const document = h.document([input]);
const document = Document.of([input]);

t.deepEqual(await evaluate(R12, { document }), [
passed(R12, input, {
Expand All @@ -31,11 +31,10 @@ test(`evaluates() passes a submit button element with an accessible name given
]);
});

test(`evaluates() passes a <button> with a name given by the \`aria-label\`
attribute`, async (t) => {
test(`evaluates() passes a <button> with a name given by the \`aria-label\` attribute`, async (t) => {
const target = <button aria-label="My button"></button>;

const document = h.document([target]);
const document = Document.of([target]);

t.deepEqual(await evaluate(R12, { document }), [
passed(R12, target, {
Expand All @@ -47,7 +46,7 @@ test(`evaluates() passes a <button> with a name given by the \`aria-label\`
test(`evaluates() fails a button with no accessible name`, async (t) => {
const target = <button></button>;

const document = h.document([target]);
const document = Document.of([target]);

t.deepEqual(await evaluate(R12, { document }), [
failed(R12, target, {
Expand All @@ -59,7 +58,7 @@ test(`evaluates() fails a button with no accessible name`, async (t) => {
test(`evaluates() fails an element with \`button\` role without an accessible name`, async (t) => {
const target = <span role="button"></span>;

const document = h.document([target]);
const document = Document.of([target]);

t.deepEqual(await evaluate(R12, { document }), [
failed(R12, target, {
Expand All @@ -71,23 +70,23 @@ test(`evaluates() fails an element with \`button\` role without an accessible na
test(`evaluate() is inapplicable to image buttons`, async (t) => {
const target = <input type="image" value="download" alt="Download" />;

const document = h.document([target]);
const document = Document.of([target]);

t.deepEqual(await evaluate(R12, { document }), [inapplicable(R12)]);
});

test(`evaluate() is inapplicable to element with no button role`, async (t) => {
test(`evaluate() is inapplicabile to element with no button role`, async (t) => {
const target = <div>Press Here</div>;

const document = h.document([target]);
const document = Document.of([target]);

t.deepEqual(await evaluate(R12, { document }), [inapplicable(R12)]);
});

test(`evaluate() is inapplicable to button element with none role`, async (t) => {
test(`evaluate() is inapplicabile to button element with none role`, async (t) => {
const target = <button role="none" disabled></button>;

const document = h.document([target]);
const document = Document.of([target]);

t.deepEqual(await evaluate(R12, { document }), [inapplicable(R12)]);
});
1 change: 1 addition & 0 deletions packages/alfa-rules/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
"test/sia-r9/rule.spec.tsx",
"test/sia-r10/rule.spec.tsx",
"test/sia-r11/rule.spec.tsx",
"test/sia-r12/rule.spec.tsx",
"test/sia-r13/rule.spec.tsx",
"test/sia-r14/rule.spec.tsx",
"test/sia-r15/rule.spec.tsx",
Expand Down

0 comments on commit 91a8fbe

Please sign in to comment.