support interaction between module and apps for updating templates before rendering
[squeep-authentication-module] / test / lib / template / login-html.js
index 4d239119a49ef97e11d6c9f8afb392276ad7d6d4..04e755584d6ee7c30584ea166b7f20963946b2dd 100644 (file)
@@ -3,14 +3,7 @@
 
 const assert = require('assert');
 const { LoginHTML } = require('../../../lib/template');
-const stubLogger = require('../../stub-logger');
-const lint = require('html-minifier-lint').lint; // eslint-disable-line node/no-unpublished-require
-
-function lintHtml(html) {
-  const result = lint(html);
-  stubLogger.debug('validHtml', '', { result, html });
-  assert(!result);
-}
+const lintHtml = require('../../lint-html');
 
 describe('Template LoginHTML', function () {
   let ctx, options;
@@ -20,7 +13,7 @@ describe('Template LoginHTML', function () {
     };
     options = {
       authenticator: {
-        authnEnabled: ['indieAuth', 'DEBUG_ANY'],
+        authnEnabled: ['indieAuth'],
         secureAuthOnly: true,
       },
       manager: {
@@ -32,42 +25,49 @@ describe('Template LoginHTML', function () {
     };
   });
 
-  it('covers', function () {
+  it('covers', async function () {
+    const result = LoginHTML(ctx, options);
+    await lintHtml(result);
+    assert(result);
+  });
+
+  it('covers local user', async function () {
+    options.authenticator.authnEnabled = ['argon2'];
     const result = LoginHTML(ctx, options);
-    lintHtml(result);
+    await lintHtml(result);
     assert(result);
   });
 
-  it('renders errors and additional content', function () {
+  it('renders errors and additional content', async function () {
     ctx.errors = ['an error', 'another error'];
     options.manager.logoUrl = 'https://example.com/logo.png';
     options.authenticator.loginBlurb = ['<p>This is a login page.</p>'];
     options.authenticator.indieAuthBlurb = ['<p>Describe what IndieAuth allows one to do.</p>'];
     options.authenticator.userBlurb = ['<p>Describe user login.</p>'];
     const result = LoginHTML(ctx, options);
-    lintHtml(result);
+    await lintHtml(result);
     assert(result);
   });
 
-  it('covers no indieAuth', function () {
+  it('covers no indieAuth', async function () {
     options.authenticator.authnEnabled = [];
     const result = LoginHTML(ctx, options);
-    lintHtml(result);
+    await lintHtml(result);
     assert(result);
   });
 
-  it('covers insecure not allowed', function () {
+  it('covers insecure not allowed', async function () {
     ctx.clientProtocol = undefined;
     const result = LoginHTML(ctx, options);
-    lintHtml(result);
+    await lintHtml(result);
     assert(result);
   });
 
-  it('covers insecure allowed', function () {
+  it('covers insecure allowed', async function () {
     ctx.clientProtocol = 'http';
     options.authenticator.secureAuthOnly = false;
     const result = LoginHTML(ctx, options);
-    lintHtml(result);
+    await lintHtml(result);
     assert(result);
   });