diff --git a/packages/alfa-rules/test/sia-r115/rule.spec.tsx b/packages/alfa-rules/test/sia-r115/rule.spec.tsx new file mode 100644 index 0000000000..e782c037f2 --- /dev/null +++ b/packages/alfa-rules/test/sia-r115/rule.spec.tsx @@ -0,0 +1,85 @@ +import { Outcome } from "@siteimprove/alfa-act"; +import { h } from "@siteimprove/alfa-dom"; +import { test } from "@siteimprove/alfa-test"; + +import R115, { Outcomes } from "../../dist/sia-r115/rule.js"; + +import { evaluate } from "../common/evaluate.js"; +import { oracle } from "../common/oracle.js"; +import { cantTell, failed, inapplicable, passed } from "../common/outcome.js"; + +const goodHeading =
We are open 10:00 to 18:00 daily.
, +]); + +const badHeading =We are open 10:00 to 18:00 daily.
, +]); + +test("evaluate() passes heading describing the following content", async (t) => { + t.deepEqual( + await evaluate( + R115, + { document: goodDocument }, + oracle({ "is-heading-descriptive": true }), + ), + [ + passed( + R115, + goodHeading, + { 1: Outcomes.HeadingIsDescriptive }, + Outcome.Mode.SemiAuto, + ), + ], + ); +}); + +test("evaluate() fails headings who do not describe the following content", async (t) => { + t.deepEqual( + await evaluate( + R115, + { document: badDocument }, + oracle({ "is-heading-descriptive": false }), + ), + [ + failed( + R115, + badHeading, + { 1: Outcomes.HeadingIsNotDescriptive }, + Outcome.Mode.SemiAuto, + ), + ], + ); +}); + +test("evaluate() can't tell if questions are left unanswered", async (t) => { + t.deepEqual(await evaluate(R115, { document: goodDocument }), [ + cantTell(R115, goodHeading), + ]); +}); + +test("evaluate() is inapplicable when there is no headings", async (t) => { + const document = h.document([ + +Some text in English
, + ]); + + t.deepEqual(await evaluate(R115, { document }), [inapplicable(R115)]); +}); diff --git a/packages/alfa-rules/test/tsconfig.json b/packages/alfa-rules/test/tsconfig.json index 3a99845ba0..ba815db1e1 100644 --- a/packages/alfa-rules/test/tsconfig.json +++ b/packages/alfa-rules/test/tsconfig.json @@ -118,7 +118,8 @@ "./sia-r110/rule.spec.tsx", "./sia-r111/rule.spec.tsx", "./sia-r113/rule.spec.tsx", - "./sia-r114/rule.spec.tsx" + "./sia-r114/rule.spec.tsx", + "./sia-r115/rule.spec.tsx" ], "references": [{ "path": "../src" }, { "path": "../../alfa-test" }] }