From: Justin Wind <justin.wind+git@gmail.com>
Date: Sat, 25 Jan 2025 22:38:57 +0000 (-0800)
Subject: add tests on lint-html test helper
X-Git-Tag: v1.6.2~2
X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=357db466f6ad6d5d7f8dfdf2836ae6ffc037e430;p=squeep-html-template-helper

add tests on lint-html test helper
---

diff --git a/test/lint-html.test.js b/test/lint-html.test.js
new file mode 100644
index 0000000..123072e
--- /dev/null
+++ b/test/lint-html.test.js
@@ -0,0 +1,32 @@
+'use strict';
+
+const assert = require('node:assert');
+const { HtmlValidate } = require('html-validate');
+const { makeHtmlLint } = require('./lint-html');
+const stubLogger = require('./stub-logger');
+
+describe('LintHTML', function () {
+  let htmlLint, htmlValidate;
+  beforeEach(function () {
+    htmlValidate = new HtmlValidate();
+    htmlLint = makeHtmlLint(stubLogger, htmlValidate);
+  });
+  describe('htmlLint', function () {
+    it('validates valid html', async function () {
+      this.slow(1000); // First invocation of htmlLint takes some time.
+      const html = `<html lang="en">
+  <head>
+    <title>Test Page</title>
+  </head>
+  <body>
+  </body>
+    </html>`;
+      await htmlLint(html);
+    });
+    it('does not validate invalid html', async function () {
+      const html = `<html><head><title>Bad Page</title></head><body><div></body></html>`;
+      assert.rejects(htmlLint(html));
+    });
+  }); // htmlLint
+
+}); // LintHTML
\ No newline at end of file