X-Git-Url: http://git.squeep.com/?p=squeep-indie-auther;a=blobdiff_plain;f=test%2Fsrc%2Ftemplate%2Fadmin-ticket-html.js;fp=test%2Fsrc%2Ftemplate%2Fadmin-ticket-html.js;h=9622aa5acdea1738417d6b5950fbdc4d44d022bc;hp=0000000000000000000000000000000000000000;hb=b0103b0d496262c438b40bc20304081dbfe41e73;hpb=8ed81748bce7cea7904cac7225b20a60cafdfc16 diff --git a/test/src/template/admin-ticket-html.js b/test/src/template/admin-ticket-html.js new file mode 100644 index 0000000..9622aa5 --- /dev/null +++ b/test/src/template/admin-ticket-html.js @@ -0,0 +1,87 @@ +/* eslint-env mocha */ +'use strict'; + +const assert = require('assert'); +const template = require('../../../src/template/admin-ticket-html'); +const Config = require('../../../config'); +const StubLogger = require('../../stub-logger'); +const lint = require('html-minifier-lint').lint; // eslint-disable-line node/no-unpublished-require + +const stubLogger = new StubLogger(); + +function lintHtml(html) { + const result = lint(html); + stubLogger.debug('validHtml', '', { result, html }); + assert(!result); +} + +describe('Admin Ticket HTML Template', function () { + let ctx, config; + beforeEach(function () { + ctx = { + profilesScopes: { + scopeIndex: { + 'profile': { + application: '', + description: '', + isPermanent: true, + isManuallyAdded: false, + profiles: ['https://example.com/'], + }, + 'other_scope': { + application: 'app1', + description: '', + isPermanent: false, + isManuallyAdded: true, + profiles: [], + }, + 'read': { + application: 'app2', + description: '', + isPermanent: true, + isManuallyAdded: false, + profiles: [], + }, + 'scopitty_scope': { + application: 'app2', + description: '', + isPermanent: false, + isManuallyAdded: false, + profiles: [], + }, + 'last_scope': { + application: 'app1', + description: '', + isPermanent: false, + isManuallyAdded: false, + profiles: [], + }, + }, + profileScopes: { + 'https://example.com': { + 'profile': { + application: '', + description: '', + isPermanent: true, + isManuallyAdded: false, + profiles: ['https://example.com/'], + }, + }, + }, + profiles: ['https://example.com/'], + }, + }; + config = new Config('test'); + }); + it('renders', function () { + const result = template(ctx, config); + lintHtml(result); + assert(result); + }); + it('covers branches', function () { + delete ctx.profilesScopes; + const result = template(ctx, config); + lintHtml(result); + assert(result); + }); +}); // Admin Ticket HTML Template