fix typo in ticket template causing extraneous navLink to be displayed
[squeep-indie-auther] / test / src / template / admin-html.js
1 /* eslint-env mocha */
2 'use strict';
3
4 const assert = require('assert');
5 const template = require('../../../src/template/admin-html');
6 const Config = require('../../../config');
7 const StubLogger = require('../../stub-logger');
8 const { makeHtmlLint } = require('@squeep/html-template-helper');
9 const { HtmlValidate } = require('html-validate');
10
11 const stubLogger = new StubLogger();
12 const htmlValidate = new HtmlValidate({
13 extends: [
14 'html-validate:recommended',
15 ],
16 rules: {
17 'valid-id': ['error', { relaxed: true }], // allow profile uri to be component of id
18 },
19 });
20 const lintHtml = makeHtmlLint(stubLogger, htmlValidate);
21
22 describe('Admin HTML Template', function () {
23 let ctx, config;
24 beforeEach(function () {
25 ctx = {
26 profilesScopes: {
27 scopeIndex: {
28 'scope': {
29 application: '',
30 description: '',
31 isPermanent: true,
32 isManuallyAdded: false,
33 profiles: ['https://example.com/'],
34 },
35 'other_scope': {
36 application: 'app1',
37 description: '',
38 isPermanent: false,
39 isManuallyAdded: true,
40 profiles: [],
41 },
42 'more_scope': {
43 application: 'app2',
44 description: '',
45 isPermanent: false,
46 isManuallyAdded: false,
47 profiles: [],
48 },
49 'scopitty_scope': {
50 application: 'app2',
51 description: '',
52 isPermanent: false,
53 isManuallyAdded: false,
54 profiles: [],
55 },
56 'last_scope': {
57 application: 'app1',
58 description: '',
59 isPermanent: false,
60 isManuallyAdded: false,
61 profiles: [],
62 },
63 },
64 profiles: ['https://example.com/'],
65 },
66 tokens: [
67 {
68 codeId: 'xxx',
69 clientId: 'https://client.example.com/',
70 profile: 'https://profile.example.com/',
71 created: new Date(),
72 expires: null,
73 isRevoked: false,
74 },
75 {
76 codeId: 'yyy',
77 clientId: 'https://client.example.com/',
78 profile: 'https://profile.example.com/',
79 isToken: true,
80 created: new Date(Date.now() - 86400000),
81 refreshed: new Date(),
82 expires: new Date(Date.now() + 86400000),
83 isRevoked: true,
84 },
85 {
86 codeId: 'zzz',
87 clientId: 'https://client.exmaple.com/',
88 profile: 'https://profile.example.com/',
89 resource: 'https://resource.example.com/',
90 created: new Date(),
91 scopes: ['read'],
92 },
93 ],
94 };
95 config = new Config('test');
96 });
97 it('renders', async function () {
98 const result = template(ctx, config);
99 await lintHtml(result);
100 assert(result);
101 });
102 it('renders no tokens', async function () {
103 ctx.tokens = [];
104 const result = template(ctx, config);
105 await lintHtml(result);
106 assert(result);
107 });
108 it('covers options', async function () {
109 delete ctx.profilesScopes.profiles;
110 delete ctx.profilesScopes.scopeIndex.scope.profiles;
111 delete ctx.tokens;
112 const result = template(ctx, config);
113 await lintHtml(result);
114 assert(result);
115 });
116 }); // Admin HTML Template