diff --git a/packages/alfa-rules/test/sia-r5/rule.spec.tsx b/packages/alfa-rules/test/sia-r5/rule.spec.tsx new file mode 100644 index 0000000000..a24953638e --- /dev/null +++ b/packages/alfa-rules/test/sia-r5/rule.spec.tsx @@ -0,0 +1,51 @@ +import { test } from "@siteimprove/alfa-test"; + +import { Document } from "@siteimprove/alfa-dom"; + +import R5, { Outcomes } from "../../src/sia-r5/rule"; + +import { evaluate } from "../common/evaluate"; +import { passed, failed, inapplicable } from "../common/outcome"; + +test(`evaluate() passes a lang attribute with valid primary tag`, async (t) => { + const html = ; + + const document = Document.of([html]); + + t.deepEqual(await evaluate(R5, { document }), [ + passed(R5, html.attribute("lang").get(), { + 1: Outcomes.HasValidLanguage, + }), + ]); +}); + +test(`evaluate() passes a lang attribute with valid primary tag and invalid region subtag`, async (t) => { + const html = ; + + const document = Document.of([html]); + + t.deepEqual(await evaluate(R5, { document }), [ + passed(R5, html.attribute("lang").get(), { + 1: Outcomes.HasValidLanguage, + }), + ]); +}); + +test(`evaluate() fails a lang attribute with invalid primary tag.`, async (t) => { + const html = ; + + const document = Document.of([html]); + + t.deepEqual(await evaluate(R5, { document }), [ + failed(R5, html.attribute("lang").get(), { + 1: Outcomes.HasNoValidLanguage, + }), + ]); +}); + +test(`evaluate() is inapplicable to svg elements.`, async (t) => { + const html = ; + const document = Document.of([html]); + + t.deepEqual(await evaluate(R5, { document }), [inapplicable(R5)]); +}); diff --git a/packages/alfa-rules/tsconfig.json b/packages/alfa-rules/tsconfig.json index e94faed657..cddf17b7d7 100644 --- a/packages/alfa-rules/tsconfig.json +++ b/packages/alfa-rules/tsconfig.json @@ -156,6 +156,7 @@ "test/sia-r2/rule.spec.tsx", "test/sia-r3/rule.spec.tsx", "test/sia-r4/rule.spec.tsx", + "test/sia-r5/rule.spec.tsx", "test/sia-r6/rule.spec.tsx", "test/sia-r7/rule.spec.tsx", "test/sia-r9/rule.spec.tsx",