X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fsrc%2Fservice.js;h=576859f834156b09759c2b64f7b29cee31de0e53;hb=71587de3ea9839d14d9f7bffa6c1db19e52dd9b5;hp=2de3b52c4595772834636f38be58b10fb54f9f6a;hpb=749801f9983b087aee6844ee5fa0f0a7419ec5db;p=websub-hub diff --git a/test/src/service.js b/test/src/service.js index 2de3b52..576859f 100644 --- a/test/src/service.js +++ b/test/src/service.js @@ -21,6 +21,7 @@ describe('Service', function () { asyncLocalStorage = new AsyncLocalStorage(); options = new Config('test'); service = new Service(stubLogger, stubDb, options, asyncLocalStorage); + stubLogger._reset(); sinon.stub(service.manager); sinon.stub(service.sessionManager); sinon.stub(service.authenticator); @@ -49,7 +50,7 @@ describe('Service', function () { }); describe('preHandler', function () { - it('logs requestId', async () => { + it('logs requestId', async function () { sinon.stub(service.__proto__.__proto__, 'preHandler').resolves(); await service.asyncLocalStorage.run({}, async () => { await service.preHandler(req, res, ctx); @@ -57,6 +58,12 @@ describe('Service', function () { assert('requestId' in logObject); }); }); + it('covers weird async context failure', async function () { + sinon.stub(service.__proto__.__proto__, 'preHandler').resolves(); + sinon.stub(service.asyncLocalStorage, 'getStore').returns(); + await service.preHandler(req, res, ctx); + assert(service.logger.debug.called); + }); }); // preHandler describe('maybeIngestBody', function () { @@ -197,7 +204,7 @@ describe('Service', function () { await service.handlerGetAdminLogout(req, res, ctx); assert(service.sessionManager.getAdminLogout.called); }); -}); // handlerGetAdminLogout + }); // handlerGetAdminLogout describe('handlerGetAdminIA', function () { it('covers', async function () {