diff --git a/packages/alfa-rules/test/sia-r12/rule.spec.tsx b/packages/alfa-rules/test/sia-r12/rule.spec.tsx new file mode 100644 index 0000000000..a3de061309 --- /dev/null +++ b/packages/alfa-rules/test/sia-r12/rule.spec.tsx @@ -0,0 +1,92 @@ +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 ; + + const document = Document.of([target]); + + t.deepEqual(await evaluate(R12, { document }), [ + passed(R12, target, { + 1: Outcomes.HasName, + }), + ]); +}); + +test(`evaluates() passes a submit button element with an accessible name given by the value attribute `, async (t) => { + const input = ; + + const document = Document.of([input]); + + t.deepEqual(await evaluate(R12, { document }), [ + passed(R12, input, { + 1: Outcomes.HasName, + }), + ]); +}); + +test(`evaluates() passes a ; + + const document = Document.of([target]); + + t.deepEqual(await evaluate(R12, { document }), [ + passed(R12, target, { + 1: Outcomes.HasName, + }), + ]); +}); + +test(`evaluates() fails a button with no accessible name`, async (t) => { + const target = ; + + const document = Document.of([target]); + + t.deepEqual(await evaluate(R12, { document }), [ + failed(R12, target, { + 1: Outcomes.HasNoName, + }), + ]); +}); + +test(`evaluates() fails an element with \`button\` role without an accessible name`, async (t) => { + const target = ; + + const document = Document.of([target]); + + t.deepEqual(await evaluate(R12, { document }), [ + failed(R12, target, { + 1: Outcomes.HasNoName, + }), + ]); +}); + +test(`evaluate() is inapplicable to image buttons`, async (t) => { + const target = ; + + const document = Document.of([target]); + + t.deepEqual(await evaluate(R12, { document }), [inapplicable(R12)]); +}); + +test(`evaluate() is inapplicabile to element with no button role`, async (t) => { + const target =
Press Here
; + + const document = Document.of([target]); + + t.deepEqual(await evaluate(R12, { document }), [inapplicable(R12)]); +}); + +test(`evaluate() is inapplicabile to button element with none role`, async (t) => { + const target = ; + + const document = Document.of([target]); + + t.deepEqual(await evaluate(R12, { document }), [inapplicable(R12)]); +}); diff --git a/packages/alfa-rules/tsconfig.json b/packages/alfa-rules/tsconfig.json index cddf17b7d7..33b77b3d51 100644 --- a/packages/alfa-rules/tsconfig.json +++ b/packages/alfa-rules/tsconfig.json @@ -162,6 +162,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",