Skip to content

Commit

Permalink
This is how we can render tests (#36)
Browse files Browse the repository at this point in the history
* this is how we can render tests

* try ignoring some tests

* fix bad merge
  • Loading branch information
koddsson authored Jun 26, 2024
1 parent d7a7a19 commit f3c7a94
Showing 1 changed file with 58 additions and 60 deletions.
118 changes: 58 additions & 60 deletions tests/aria-tooltip-name.ts
Original file line number Diff line number Diff line change
@@ -1,60 +1,58 @@
// import { fixture, html, expect } from "@open-wc/testing";
// import { Scanner } from "../src/scanner";
// import { ariaTooltipName } from "../src/rules/aria-tooltip-name";
//
// const scanner = new Scanner([ariaTooltipName]);
//
// // TODO
// const passes = [
// // `<div role="tooltip" id="al" aria-label="Name"></div>`,
// // `<div>
// // <div role="tooltip" id="alb" aria-labelledby="labeldiv"></div>
// // <div id="labeldiv">Hello world!</div>
// // </div>`,
// // `<div role="tooltip" id="combo" aria-label="Aria Name">Name</div>`,
// // `<div role="tooltip" id="title" title="Title"></div>`,
// ];
//
// const violations = [
// // `<div role="tooltip" id="empty"></div>`,
// // `<div role="tooltip" id="alempty" aria-label=""></div>`,
// // `<div
// // role="tooltip"
// // id="albmissing"
// // aria-labelledby="nonexistent"
// // ></div>`,
// // `<div>
// // <div role="tooltip" id="albempty" aria-labelledby="emptydiv"></div>
// // <div id="emptydiv"></div>
// // </div>`,
// ];
//
// describe.skip("aria-tooltip-name", async function () {
// for (const markup of passes) {
// const el = await fixture(markup);
// it(el.outerHTML, async () => {
// const results = (await scanner.scan(el)).map(({ text, url }) => {
// return { text, url };
// });
//
// expect(results).to.be.empty;
// });
// }
//
// for await (const markup of violations) {
// const el = await fixture(markup);
// it(el.outerHTML, async () => {
// const results = (await scanner.scan(el)).map(({ text, url }) => {
// return { text, url };
// });
//
// expect(results).to.eql([
// {
// text: "ARIA tooltip must have an accessible name",
// url: "https://dequeuniversity.com/rules/axe/4.4/aria-tooltip-name?application=RuleDescription",
// },
// ]);
// });
// }
// });
//
import { fixture, expect } from "@open-wc/testing";
import { Scanner } from "../src/scanner";
import { ariaTooltipName } from "../src/rules/aria-tooltip-name";

const scanner = new Scanner([ariaTooltipName]);

const passes = [
`<div role="tooltip" id="al" aria-label="Name"></div>`,
`<div>
<div role="tooltip" id="alb" aria-labelledby="labeldiv"></div>
<div id="labeldiv">Hello world!</div>
</div>`,
`<div role="tooltip" id="combo" aria-label="Aria Name">Name</div>`,
`<div role="tooltip" id="title" title="Title"></div>`,
];

const violations = [
`<div role="tooltip" id="empty"></div>`,
`<div role="tooltip" id="alempty" aria-label=""></div>`,
`<div
role="tooltip"
id="albmissing"
aria-labelledby="nonexistent"
></div>`,
`<div>
<div role="tooltip" id="albempty" aria-labelledby="emptydiv"></div>
<div id="emptydiv"></div>
</div>`,
];

describe("aria-tooltip-name", async function () {
for (const markup of passes) {
const el = await fixture(markup);
it(el.outerHTML, async function () {
const results = (await scanner.scan(el)).map(({ text, url }) => {
return { text, url };
});

expect(results).to.be.empty;
});
}

for (const markup of violations) {
const el = await fixture(markup);
it(el.outerHTML, async function () {
const results = (await scanner.scan(el)).map(({ text, url }) => {
return { text, url };
});

expect(results).to.eql([
{
text: "ARIA tooltip must have an accessible name",
url: "https://dequeuniversity.com/rules/axe/4.4/aria-tooltip-name?application=RuleDescription",
},
]);
});
}
});

0 comments on commit f3c7a94

Please sign in to comment.