-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Test r5 added * Apply suggestions from code review Co-authored-by: Jean-Yves Moyen <[email protected]> * variable const target changed to html Co-authored-by: Jean-Yves Moyen <[email protected]>
- Loading branch information
1 parent
f66b35e
commit 6bc0448
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = <html lang="en"></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 = <html lang="en-US-GB"></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 = <html lang="invalid"></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 = <svg xmlns="http://www.w3.org/2000/svg" lang="fr"></svg>; | ||
const document = Document.of([html]); | ||
|
||
t.deepEqual(await evaluate(R5, { document }), [inapplicable(R5)]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters