Skip to content

Commit

Permalink
_all-pages test support code in one module
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-preston committed Jul 18, 2024
1 parent 0dd759a commit 8443947
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion _all-pages/hljsCoverage.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assertArrayIncludes } from "assert";
import { siteFiles } from "./siteFiles.ts";
import { siteFiles } from "./testing.ts";

const hljsClassesIn = (path: string): IterableIterator<RegExpExecArray> =>
Deno.readTextFileSync(path).matchAll(/hljs-\w+/g);
Expand Down
2 changes: 1 addition & 1 deletion _all-pages/hljsWorkaround.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* cSpell:words hljs */

import { assertEquals } from "assert";
import { documentFromHtml, documentToHtml } from "testDom";
import { hljsWorkaround } from "./hljsWorkaround.ts";
import { documentFromHtml, documentToHtml } from "./testing.ts";

Deno.test("It removes all .hljs-number elements within a .language-dockerfile", () => {
const originalHtml = [
Expand Down
6 changes: 0 additions & 6 deletions _all-pages/siteFiles.ts

This file was deleted.

2 changes: 1 addition & 1 deletion _all-pages/stripWhitespace.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assertEquals } from "assert";
import { documentFromHtml, documentToHtml } from "testDom";
import { stripWhitespace } from "./stripWhitespace.ts";
import { documentFromHtml, documentToHtml } from "./testing.ts";

Deno.test("It removes all whitespace", () => {
const document = documentFromHtml([
Expand Down
6 changes: 6 additions & 0 deletions _all-pages/testDom.ts → _all-pages/testing.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { type FileInfo, default as getFiles } from "getFiles";
import { DOMParser } from "lume/deps/dom.ts";

export const documentFromHtml = (html: string | Array<string>): Document => {
Expand All @@ -10,3 +11,8 @@ export const documentFromHtml = (html: string | Array<string>): Document => {

export const documentToHtml = (document: Document): string =>
document.documentElement.outerHTML;

export const siteFiles = (extension: string): Array<string> =>
getFiles({ "root": "./_site" })
.filter((file: FileInfo): boolean => file.ext == extension)
.map((file: FileInfo): string => file.path);
2 changes: 1 addition & 1 deletion _all-pages/validHtml.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert } from "assert";
import { HtmlValidate, formatterFactory } from "htmlValidate";
import { siteFiles } from "./siteFiles.ts";
import { siteFiles } from "./testing.ts";

Deno.test("Output HTML files are valid", async () => {
const htmlValidate = new HtmlValidate();
Expand Down

0 comments on commit 8443947

Please sign in to comment.