X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Fsrc%2Fservice.js;h=2cfe38d66ed4b55115ebb070dcc4301c1f7b9f1d;hb=3ca7fccb306d0b23626befc3791ffa360b3db1e7;hp=576859f834156b09759c2b64f7b29cee31de0e53;hpb=71587de3ea9839d14d9f7bffa6c1db19e52dd9b5;p=websub-hub diff --git a/test/src/service.js b/test/src/service.js index 576859f..2cfe38d 100644 --- a/test/src/service.js +++ b/test/src/service.js @@ -1,10 +1,7 @@ -/* eslint-env mocha */ -/* eslint-disable capitalized-comments */ - 'use strict'; -const assert = require('assert'); -const sinon = require('sinon'); // eslint-disable-line node/no-unpublished-require +const assert = require('node:assert'); +const sinon = require('sinon'); const stubDb = require('../stub-db'); const stubLogger = require('../stub-logger'); @@ -191,6 +188,34 @@ describe('Service', function () { }); }); // handlerGetAdminLogin + describe('handlerGetAdminSettings', function () { + it('covers logged in', async function () { + service.authenticator.sessionRequiredLocal.resolves(true); + await service.handlerGetAdminSettings(req, res, ctx); + assert(service.sessionManager.getAdminSettings.called); + }); + it('covers not logged in', async function () { + service.authenticator.sessionRequiredLocal.resolves(false); + await service.handlerGetAdminSettings(req, res, ctx); + assert(service.sessionManager.getAdminSettings.notCalled); + }); + }); // handlerGetAdminSettings + + describe('handlerPostAdminSettings', function () { + it('covers logged in', async function () { + service.authenticator.sessionRequiredLocal.resolves(true); + sinon.stub(service, 'bodyData').resolves(); + await service.handlerPostAdminSettings(req, res, ctx); + assert(service.sessionManager.postAdminSettings.called); + }); + it('covers logged outo', async function () { + service.authenticator.sessionRequiredLocal.resolves(false); + sinon.stub(service, 'bodyData').resolves(); + await service.handlerPostAdminSettings(req, res, ctx); + assert(service.sessionManager.postAdminSettings.notCalled); + }); + }); // handlerPostAdminSettings + describe('handlerPostAdminLogin', function () { it('covers', async function () { sinon.stub(service, 'bodyData').resolves();