X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Fsrc%2Fmanager.js;h=67283d76b82c992058e39b2926bd699cd1d43830;hb=06565fb4b802c38a60d4c6e0f4b65c26da18d69f;hp=89e3d65fca2b8370f12de13c02e46553cdaea404;hpb=085b55f507dedc16016bb491d520c556acd60643;p=websub-hub diff --git a/test/src/manager.js b/test/src/manager.js index 89e3d65..67283d7 100644 --- a/test/src/manager.js +++ b/test/src/manager.js @@ -59,18 +59,6 @@ describe('Manager', function () { 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 () { @@ -150,7 +138,7 @@ describe('Manager', function () { }); // getInfo describe('getAdminOverview', function () { - it('covers', async function () { + beforeEach(function () { manager.db.topicGetAll.resolves([ { id: '56c557ce-e667-11eb-bd80-0025905f714a', @@ -172,13 +160,23 @@ describe('Manager', function () { 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', @@ -214,7 +212,25 @@ describe('Manager', function () { deliveryAttemptsSinceSuccess: 0, deliveryNextAttempt: new Date(-Infinity), }]); + }); + 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