initial commit
[squeep-indie-auther] / test / src / template / admin-ticket-html.js
1 /* eslint-env mocha */
2 'use strict';
3
4 const assert = require('assert');
5 const template = require('../../../src/template/admin-ticket-html');
6 const Config = require('../../../config');
7 const StubLogger = require('../../stub-logger');
8 const lint = require('html-minifier-lint').lint; // eslint-disable-line node/no-unpublished-require
9
10 const stubLogger = new StubLogger();
11
12 function lintHtml(html) {
13 const result = lint(html);
14 stubLogger.debug('validHtml', '', { result, html });
15 assert(!result);
16 }
17
18 describe('Admin Ticket HTML Template', function () {
19 let ctx, config;
20 beforeEach(function () {
21 ctx = {
22 profilesScopes: {
23 scopeIndex: {
24 'profile': {
25 application: '',
26 description: '',
27 isPermanent: true,
28 isManuallyAdded: false,
29 profiles: ['https://example.com/'],
30 },
31 'other_scope': {
32 application: 'app1',
33 description: '',
34 isPermanent: false,
35 isManuallyAdded: true,
36 profiles: [],
37 },
38 'read': {
39 application: 'app2',
40 description: '',
41 isPermanent: true,
42 isManuallyAdded: false,
43 profiles: [],
44 },
45 'scopitty_scope': {
46 application: 'app2',
47 description: '',
48 isPermanent: false,
49 isManuallyAdded: false,
50 profiles: [],
51 },
52 'last_scope': {
53 application: 'app1',
54 description: '',
55 isPermanent: false,
56 isManuallyAdded: false,
57 profiles: [],
58 },
59 },
60 profileScopes: {
61 'https://example.com': {
62 'profile': {
63 application: '',
64 description: '',
65 isPermanent: true,
66 isManuallyAdded: false,
67 profiles: ['https://example.com/'],
68 },
69 },
70 },
71 profiles: ['https://example.com/'],
72 },
73 };
74 config = new Config('test');
75 });
76 it('renders', function () {
77 const result = template(ctx, config);
78 lintHtml(result);
79 assert(result);
80 });
81 it('covers branches', function () {
82 delete ctx.profilesScopes;
83 const result = template(ctx, config);
84 lintHtml(result);
85 assert(result);
86 });
87 }); // Admin Ticket HTML Template