Skip to content

Commit

Permalink
better hljsCoverage.test
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-preston committed Jul 18, 2024
1 parent e08c191 commit 0dd759a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions _all-pages/hljsCoverage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,34 @@ const hljsClassesIn = (path: string): IterableIterator<RegExpExecArray> =>

Deno.test("hljs styles that are used are covered in CSS", () => {
let styles: Array<string> = [];

for (const path of siteFiles("css")) {
styles = styles.concat(
Array.from(hljsClassesIn(path)).map(
(match: RegExpExecArray): string => match[0]
)
);
}

styles = [...new Set(styles)];
for (const path of siteFiles("html")) {
for (const usedClass of hljsClassesIn(path)) {
assertArrayIncludes(styles, [usedClass[0]]);
}
}
});

Deno.test("hljs styles that are in CSS are used", () => {
let usedClasses: Array<string> = [];
for (const path of siteFiles("html")) {
usedClasses = usedClasses.concat(
Array.from(hljsClassesIn(path)).map(
(match: RegExpExecArray): string => match[0]
)
);
}
usedClasses = [...new Set(usedClasses)];
for (const path of siteFiles("css")) {
for (const style of hljsClassesIn(path)) {
assertArrayIncludes(usedClasses, [style[0]]);
}
}
});

0 comments on commit 0dd759a

Please sign in to comment.