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;
beforeEach(function () {
pagePathLevel = 2;
ctx = {};
- options = {
- pageTitle: 'Test Page',
- };
+ options = {};
});
describe('initContext', function () {
});
}); // renderNavLink
+ describe('elementAttributes', function () {
+ it('covers', function () {
+ const attributes = {
+ class: 'foo bar',
+ disabled: '',
+ };
+ const result = th.elementAttributes(attributes);
+ assert.strictEqual(result, ' class="foo bar" disabled');
+ });
+ }); // elementAttributes
+
describe('OL', function () {
it('covers', function () {
const result = th.OL(['item', 'another item'], 1, { class: 'class' }, (item) => ({ class: `${item}-class` }));
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 () {
+ this.slow(1000); // First invocation of htmlLint takes some time.
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 () {
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 () {
};
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 () {
};
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 () {
href: 'link',
}];
const result = th.htmlPage(pagePathLevel, ctx, options);
- await lintHtml.lint(result);
+ await htmlLint(result);
assert(result);
});
}); // htmlPage