};
ctx = {
params: {},
+ queryParams: {},
};
manager = new Manager(stubLogger, stubDb, options);
sinon.stub(manager.communication, 'verificationProcess');
await manager.getRoot(req, res, ctx);
assert(res.end.called);
});
- it('repeat response', async function () {
- manager.startTime = (new Date()).toGMTString();
- common.isClientCached.returns(true);
- await manager.getRoot(req, res, ctx);
- assert(res.end.called);
- });
- it('cached response', async function () {
- common.isClientCached.returns(true);
- await manager.getRoot(req, res, ctx);
- assert(res.end.called);
- assert.strictEqual(res.statusCode, 304);
- });
}); // getRoot
describe('getHealthcheck', function () {
});
}); // getInfo
- describe('getAdminOverview', function () {
+ describe('_historyBarCaption', function () {
+ it('covers today, none', function () {
+ const result = Manager._historyBarCaption(0, 0);
+ assert.strictEqual(result, 'today, no updates');
+ });
+ it('covers yesterday, singular', function () {
+ const result = Manager._historyBarCaption(1, 1);
+ assert.strictEqual(result, 'yesterday, 1 update');
+ });
+ it('covers older, plural', function () {
+ const result = Manager._historyBarCaption(7, 3);
+ assert.strictEqual(result, '7 days ago, 3 updates');
+ });
+ }); // _historyBarCaption
+
+ describe('getHistorySVG', function () {
+ beforeEach(function () {
+ manager.db.topicPublishHistory.resolves([0, 1, 2, 1, 0, 1, 2, 0, 1]);
+ });
it('covers', async function () {
+ await manager.getHistorySVG(res, ctx);
+ assert(res.end.called);
+ });
+ }); // getHistorySVG
+
+ describe('getAdminOverview', function () {
+ beforeEach(function () {
manager.db.topicGetAll.resolves([
{
id: '56c557ce-e667-11eb-bd80-0025905f714a',
subscribers: 12,
},
]);
+ });
+ it('covers', async function () {
await manager.getAdminOverview(res, ctx);
assert(res.end.called);
});
+ it('covers non-matching profile', async function () {
+ ctx.session = {
+ authenticatedProfile: 'https://different.example.com/profile',
+ };
+ await manager.getAdminOverview(res, ctx);
+ assert.deepStrictEqual(ctx.topics, []);
+ assert(res.end.called);
+ });
}); // getAdminOverview
describe('getTopicDetails', function () {
- it('covers', async function() {
+ beforeEach(function () {
ctx.params.topicId = '56c557ce-e667-11eb-bd80-0025905f714a';
manager.db.topicGetById.resolves({
id: '56c557ce-e667-11eb-bd80-0025905f714a',
deliveryAttemptsSinceSuccess: 0,
deliveryNextAttempt: new Date(-Infinity),
}]);
+ manager.db.topicPublishHistory.resolves([0, 1, 0, 1, 0]);
+ });
+ it('covers', async function() {
+ await manager.getTopicDetails(res, ctx);
+ assert(res.end.called);
+ });
+ it('covers non-matching profile', async function () {
+ ctx.session = {
+ authenticatedProfile: 'https://different.example.com/profile',
+ };
+ await manager.getTopicDetails(res, ctx);
+ assert.strictEqual(ctx.topic, null);
+ assert(res.end.called);
+ });
+ it('covers matching profile', async function () {
+ ctx.session = {
+ authenticatedProfile: 'https://example.com/profile',
+ };
await manager.getTopicDetails(res, ctx);
+ assert(ctx.topic);
assert(res.end.called);
});
}); // getTopicDetails