Skip to content

Commit f3c7a94

Browse files
authored
This is how we can render tests (#36)
* this is how we can render tests * try ignoring some tests * fix bad merge
1 parent d7a7a19 commit f3c7a94

File tree

1 file changed

+58
-60
lines changed

1 file changed

+58
-60
lines changed

tests/aria-tooltip-name.ts

Lines changed: 58 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,58 @@
1-
// import { fixture, html, expect } from "@open-wc/testing";
2-
// import { Scanner } from "../src/scanner";
3-
// import { ariaTooltipName } from "../src/rules/aria-tooltip-name";
4-
//
5-
// const scanner = new Scanner([ariaTooltipName]);
6-
//
7-
// // TODO
8-
// const passes = [
9-
// // `<div role="tooltip" id="al" aria-label="Name"></div>`,
10-
// // `<div>
11-
// // <div role="tooltip" id="alb" aria-labelledby="labeldiv"></div>
12-
// // <div id="labeldiv">Hello world!</div>
13-
// // </div>`,
14-
// // `<div role="tooltip" id="combo" aria-label="Aria Name">Name</div>`,
15-
// // `<div role="tooltip" id="title" title="Title"></div>`,
16-
// ];
17-
//
18-
// const violations = [
19-
// // `<div role="tooltip" id="empty"></div>`,
20-
// // `<div role="tooltip" id="alempty" aria-label=""></div>`,
21-
// // `<div
22-
// // role="tooltip"
23-
// // id="albmissing"
24-
// // aria-labelledby="nonexistent"
25-
// // ></div>`,
26-
// // `<div>
27-
// // <div role="tooltip" id="albempty" aria-labelledby="emptydiv"></div>
28-
// // <div id="emptydiv"></div>
29-
// // </div>`,
30-
// ];
31-
//
32-
// describe.skip("aria-tooltip-name", async function () {
33-
// for (const markup of passes) {
34-
// const el = await fixture(markup);
35-
// it(el.outerHTML, async () => {
36-
// const results = (await scanner.scan(el)).map(({ text, url }) => {
37-
// return { text, url };
38-
// });
39-
//
40-
// expect(results).to.be.empty;
41-
// });
42-
// }
43-
//
44-
// for await (const markup of violations) {
45-
// const el = await fixture(markup);
46-
// it(el.outerHTML, async () => {
47-
// const results = (await scanner.scan(el)).map(({ text, url }) => {
48-
// return { text, url };
49-
// });
50-
//
51-
// expect(results).to.eql([
52-
// {
53-
// text: "ARIA tooltip must have an accessible name",
54-
// url: "https://dequeuniversity.com/rules/axe/4.4/aria-tooltip-name?application=RuleDescription",
55-
// },
56-
// ]);
57-
// });
58-
// }
59-
// });
60-
//
1+
import { fixture, expect } from "@open-wc/testing";
2+
import { Scanner } from "../src/scanner";
3+
import { ariaTooltipName } from "../src/rules/aria-tooltip-name";
4+
5+
const scanner = new Scanner([ariaTooltipName]);
6+
7+
const passes = [
8+
`<div role="tooltip" id="al" aria-label="Name"></div>`,
9+
`<div>
10+
<div role="tooltip" id="alb" aria-labelledby="labeldiv"></div>
11+
<div id="labeldiv">Hello world!</div>
12+
</div>`,
13+
`<div role="tooltip" id="combo" aria-label="Aria Name">Name</div>`,
14+
`<div role="tooltip" id="title" title="Title"></div>`,
15+
];
16+
17+
const violations = [
18+
`<div role="tooltip" id="empty"></div>`,
19+
`<div role="tooltip" id="alempty" aria-label=""></div>`,
20+
`<div
21+
role="tooltip"
22+
id="albmissing"
23+
aria-labelledby="nonexistent"
24+
></div>`,
25+
`<div>
26+
<div role="tooltip" id="albempty" aria-labelledby="emptydiv"></div>
27+
<div id="emptydiv"></div>
28+
</div>`,
29+
];
30+
31+
describe("aria-tooltip-name", async function () {
32+
for (const markup of passes) {
33+
const el = await fixture(markup);
34+
it(el.outerHTML, async function () {
35+
const results = (await scanner.scan(el)).map(({ text, url }) => {
36+
return { text, url };
37+
});
38+
39+
expect(results).to.be.empty;
40+
});
41+
}
42+
43+
for (const markup of violations) {
44+
const el = await fixture(markup);
45+
it(el.outerHTML, async function () {
46+
const results = (await scanner.scan(el)).map(({ text, url }) => {
47+
return { text, url };
48+
});
49+
50+
expect(results).to.eql([
51+
{
52+
text: "ARIA tooltip must have an accessible name",
53+
url: "https://dequeuniversity.com/rules/axe/4.4/aria-tooltip-name?application=RuleDescription",
54+
},
55+
]);
56+
});
57+
}
58+
});

0 commit comments

Comments
 (0)