X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Flib%2Ftemplate-helper.js;h=75481adfee0b010330cc89a39656fd7f28e862ef;hb=77f0fd50c8de53072f73052a01f69c6c6fc783f8;hp=58985ccd962683f175f29a879a189d708b913335;hpb=a2c0e2fc57bb8f25f694e16eb4e51d6970b28829;p=squeep-html-template-helper diff --git a/test/lib/template-helper.js b/test/lib/template-helper.js index 58985cc..75481ad 100644 --- a/test/lib/template-helper.js +++ b/test/lib/template-helper.js @@ -3,14 +3,12 @@ const assert = require('assert'); const th = require('../../lib/template-helper'); -const lint = require('html-minifier-lint').lint; // eslint-disable-line node/no-unpublished-require const stubLogger = require('../stub-logger'); -function lintHtml(html) { - const result = lint(html); - stubLogger.debug('validHtml', '', { result, html }); - assert(!result); -} +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; @@ -264,45 +262,53 @@ 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 = ['']; + options.pageTitle = 'Test Page'; + main = [ + th.UL(['an item', 'another item']), + th.timeElement(new Date(), { title: 'now' }), + ]; }); - it('covers', function () { + it('covers', async function () { const result = th.htmlPage(pagePathLevel, ctx, options, main); - lintHtml(result); + await htmlLint(result); assert(result); }); - it('covers defaults', function () { + it('covers defaults', async function () { const result = th.htmlPage(pagePathLevel, ctx, options, main); - lintHtml(result); + await htmlLint(result); assert(result); }); - it('covers user', function () { + it('covers user', async function () { ctx.session = { authenticatedProfile: 'https://user.example.com/', }; const result = th.htmlPage(pagePathLevel, ctx, options, main); - lintHtml(result); + await htmlLint(result); assert(result); }); - it('covers user at root path', function () { + it('covers user at root path', async function () { ctx.session = { authenticatedIdentifier: 'user', }; pagePathLevel = 0; const result = th.htmlPage(pagePathLevel, ctx, options, main); - lintHtml(result); + await htmlLint(result); assert(result); }); - it('covers logout redirect', function () { + it('covers logout redirect', async function () { ctx.session = { authenticatedIdentifier: 'user', }; ctx.url = 'https://app.example.com/this_page'; const result = th.htmlPage(pagePathLevel, ctx, options, main); - lintHtml(result); + await htmlLint(result); assert(result); }); - it('covers existing navLinks', function () { + it('covers existing navLinks', async function () { ctx.session = { authenticatedIdentifier: 'user', }; @@ -311,7 +317,7 @@ describe('Template Helper', function () { href: 'link', }]; const result = th.htmlPage(pagePathLevel, ctx, options); - lintHtml(result); + await htmlLint(result); assert(result); }); }); // htmlPage