display history of topic updates on topic details page
[websub-hub] / test / src / template / template-helper.js
1 /* eslint-env mocha */
2 'use strict';
3
4 const assert = require('assert');
5 const th = require('../../../src/template/template-helper');
6
7 describe('Template Helper', function () {
8
9 describe('renderTopicRow', function () {
10 let topic, subscribers;
11 beforeEach(function () {
12 topic = {};
13 subscribers = [];
14 });
15 it('covers', function () {
16 const result = th.renderTopicRow(topic, subscribers);
17 assert(result);
18 });
19 it('covers empty', function () {
20 topic = null;
21 subscribers = null;
22 const result = th.renderTopicRow(topic, subscribers);
23 assert(result);
24 });
25 it('covers no link', function () {
26 subscribers = [{}, {}];
27 const result = th.renderTopicRow(topic, subscribers, false);
28 assert(result);
29 });
30 it('covers validation', function () {
31 topic.publisherValidationUrl = 'https://example.com/';
32 const result = th.renderTopicRow(topic, subscribers, false);
33 assert(result);
34 });
35 }); // renderTopicRow
36
37 describe('renderTopicRowHeader', function () {
38 it('covers', function () {
39 const result = th.renderTopicRowHeader();
40 assert(result);
41 });
42 }); // renderTopicRowHeader
43
44 describe('renderSubscriptionRow', function () {
45 let subscription;
46 beforeEach(function () {
47 subscription = {};
48 });
49 it('covers', function () {
50 const result = th.renderSubscriptionRow(subscription);
51 assert(result);
52 });
53 it('covers empty', function () {
54 const result = th.renderSubscriptionRow();
55 assert(result);
56 });
57 }); // renderSubscriptionRow
58
59 describe('renderSubscriptionRowHeader', function () {
60 it('covers', function () {
61 const result = th.renderSubscriptionRowHeader();
62 assert(result);
63 });
64 }); // renderSubscriptionRowHeader
65
66 describe('xmlEscape', function () {
67 it('ignores numbers', function () {
68 const result = th.xmlEscape(3);
69 assert.strictEqual(result, 3);
70 });
71 it('ignores objects', function () {
72 const result = th.xmlEscape({});
73 assert.strictEqual(result, undefined);
74 });
75 it('escapes a thing', function () {
76 const result = th.xmlEscape('&');
77 assert.strictEqual(result, '&');
78 });
79 }); // xmlEscape
80
81 });