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');
11 const stubLogger
= new StubLogger();
12 const htmlValidate
= new HtmlValidate({
14 'html-validate:recommended',
17 'valid-id': ['error', { relaxed: true }], // allow profile uri to be component of id
20 const lintHtml
= makeHtmlLint(stubLogger
, htmlValidate
);
22 describe('Admin HTML Template', function () {
24 beforeEach(function () {
32 isManuallyAdded: false,
33 profiles: ['https://example.com/'],
39 isManuallyAdded: true,
46 isManuallyAdded: false,
53 isManuallyAdded: false,
60 isManuallyAdded: false,
64 profiles: ['https://example.com/'],
69 clientId: 'https://client.example.com/',
70 profile: 'https://profile.example.com/',
77 clientId: 'https://client.example.com/',
78 profile: 'https://profile.example.com/',
80 created: new Date(Date
.now() - 86400000),
81 refreshed: new Date(),
82 expires: new Date(Date
.now() + 86400000),
87 clientId: 'https://client.exmaple.com/',
88 profile: 'https://profile.example.com/',
89 resource: 'https://resource.example.com/',
95 config
= new Config('test');
97 it('renders', async
function () {
98 const result
= template(ctx
, config
);
99 await
lintHtml(result
);
102 it('renders no tokens', async
function () {
104 const result
= template(ctx
, config
);
105 await
lintHtml(result
);
108 it('covers options', async
function () {
109 delete ctx
.profilesScopes
.profiles
;
110 delete ctx
.profilesScopes
.scopeIndex
.scope
.profiles
;
112 const result
= template(ctx
, config
);
113 await
lintHtml(result
);
116 }); // Admin HTML Template