lint cleanup
[websub-hub] / test / src / service.js
index 2de3b52c4595772834636f38be58b10fb54f9f6a..576859f834156b09759c2b64f7b29cee31de0e53 100644 (file)
@@ -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 () {