initial commit
[squeep-authentication-module] / test / lib / template / ia-html.js
diff --git a/test/lib/template/ia-html.js b/test/lib/template/ia-html.js
new file mode 100644 (file)
index 0000000..8bb1a6c
--- /dev/null
@@ -0,0 +1,42 @@
+/* eslint-env mocha */
+'use strict';
+
+const assert = require('assert');
+const { IAHTML } = 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);
+}
+
+describe('Template IAHTML', function () {
+  let ctx, options;
+  beforeEach(function () {
+    ctx = {};
+    options = {
+      manager: {
+        pageTitle: 'page',
+      },
+      dingus: {
+        selfBaseUrl: 'https://example.com/',
+      },
+    };
+  });
+
+  it('renders', function () {
+    ctx.errors = ['an error', 'another error'];
+    const result = IAHTML(ctx, options);
+    lintHtml(result);
+    assert(result);
+  });
+
+  it('covers empty error', function () {
+    const result = IAHTML(ctx, options);
+    lintHtml(result);
+    assert(result);
+  });
+
+});
\ No newline at end of file