4 const assert
= require('assert');
5 const { LoginHTML
} = require('../../../lib/template');
6 const stubLogger
= require('../../stub-logger');
7 const lint
= require('html-minifier-lint').lint
; // eslint-disable-line node/no-unpublished-require
9 function lintHtml(html
) {
10 const result
= lint(html
);
11 stubLogger
.debug('validHtml', '', { result
, html
});
15 describe('Template LoginHTML', function () {
17 beforeEach(function () {
19 clientProtocol: 'https',
23 authnEnabled: ['indieAuth', 'DEBUG_ANY'],
30 selfBaseUrl: 'https://example.com/',
35 it('covers', function () {
36 const result
= LoginHTML(ctx
, options
);
41 it('renders errors and additional content', function () {
42 ctx
.errors
= ['an error', 'another error'];
43 options
.manager
.logoUrl
= 'https://example.com/logo.png';
44 options
.authenticator
.loginBlurb
= ['<p>This is a login page.</p>'];
45 options
.authenticator
.indieAuthBlurb
= ['<p>Describe what IndieAuth allows one to do.</p>'];
46 options
.authenticator
.userBlurb
= ['<p>Describe user login.</p>'];
47 const result
= LoginHTML(ctx
, options
);
52 it('covers no indieAuth', function () {
53 options
.authenticator
.authnEnabled
= [];
54 const result
= LoginHTML(ctx
, options
);
59 it('covers insecure not allowed', function () {
60 ctx
.clientProtocol
= undefined;
61 const result
= LoginHTML(ctx
, options
);
66 it('covers insecure allowed', function () {
67 ctx
.clientProtocol
= 'http';
68 options
.authenticator
.secureAuthOnly
= false;
69 const result
= LoginHTML(ctx
, options
);