minor cleanups, add logoAlt
[squeep-html-template-helper] / test / lib / template-helper.js
index 968a85f75c2f9e9651252099fefbc5eb96dc026d..75481adfee0b010330cc89a39656fd7f28e862ef 100644 (file)
@@ -4,9 +4,11 @@
 const assert = require('assert');
 const th = require('../../lib/template-helper');
 const stubLogger = require('../stub-logger');
-const LintHtml = require('../lint-html');
 
-const lintHtml = new LintHtml(stubLogger);
+const { makeHtmlLint } = require('../lint-html');
+const { HtmlValidate } = require('html-validate');
+const htmlValidate = new HtmlValidate();
+const htmlLint = makeHtmlLint(stubLogger, htmlValidate);
 
 describe('Template Helper', function () {
   let ctx, options, pagePathLevel;
@@ -14,9 +16,7 @@ describe('Template Helper', function () {
   beforeEach(function () {
     pagePathLevel = 2;
     ctx = {};
-    options = {
-      pageTitle: 'Test Page',
-    };
+    options = {};
   });
 
   describe('initContext', function () {
@@ -262,16 +262,24 @@ describe('Template Helper', function () {
   describe('htmlPage', function () {
     let main;
     beforeEach(function () {
-      main = [];
+      th.initContext(ctx);
+      ctx.errors.push('an error');
+      ctx.notifications.push('a notice');
+      options.headElements = ['<link rel="author" href="https://example.com/">'];
+      options.pageTitle = 'Test Page';
+      main = [
+        th.UL(['an item', 'another item']),
+        th.timeElement(new Date(), { title: 'now' }),
+      ];
     });
     it('covers', async function () {
       const result = th.htmlPage(pagePathLevel, ctx, options, main);
-      await lintHtml.lint(result);
+      await htmlLint(result);
       assert(result);
     });
     it('covers defaults', async function () {
       const result = th.htmlPage(pagePathLevel, ctx, options, main);
-      await lintHtml.lint(result);
+      await htmlLint(result);
       assert(result);
     });
     it('covers user', async function () {
@@ -279,7 +287,7 @@ describe('Template Helper', function () {
         authenticatedProfile: 'https://user.example.com/',
       };
       const result = th.htmlPage(pagePathLevel, ctx, options, main);
-      await lintHtml.lint(result);
+      await htmlLint(result);
       assert(result);
     });
     it('covers user at root path', async function () {
@@ -288,7 +296,7 @@ describe('Template Helper', function () {
       };
       pagePathLevel = 0;
       const result = th.htmlPage(pagePathLevel, ctx, options, main);
-      await lintHtml.lint(result);
+      await htmlLint(result);
       assert(result);
     });
     it('covers logout redirect', async function () {
@@ -297,7 +305,7 @@ describe('Template Helper', function () {
       };
       ctx.url = 'https://app.example.com/this_page';
       const result = th.htmlPage(pagePathLevel, ctx, options, main);
-      await lintHtml.lint(result);
+      await htmlLint(result);
       assert(result);
     });
     it('covers existing navLinks', async function () {
@@ -309,7 +317,7 @@ describe('Template Helper', function () {
         href: 'link',
       }];
       const result = th.htmlPage(pagePathLevel, ctx, options);
-      await lintHtml.lint(result);
+      await htmlLint(result);
       assert(result);
     });
   }); // htmlPage