X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fsrc%2Fservice.js;h=d91112548a75c6617e6b2f92987d43b74dfc1ede;hb=f0bf29c75b0fd405ff92fa76f058e61162b87e43;hp=ab6646f19ae9ecccb817388cb8bbb71a18396e82;hpb=e8dccf76ec2776f07eddd1ce2f1c4fc150a6f790;p=squeep-indie-auther diff --git a/test/src/service.js b/test/src/service.js index ab6646f..d911125 100644 --- a/test/src/service.js +++ b/test/src/service.js @@ -1,10 +1,8 @@ -/* eslint-env mocha */ -/* eslint-disable capitalized-comments */ - +/* eslint-disable sonarjs/no-duplicate-string */ 'use strict'; const assert = require('assert'); -const sinon = require('sinon'); // eslint-disable-line node/no-unpublished-require +const sinon = require('sinon'); const { AsyncLocalStorage } = require('node:async_hooks'); const StubDb = require('../stub-db'); @@ -106,6 +104,32 @@ describe('Service', function () { }); }); // handlerGetAdminLogout + describe('handlerGetAdminSettings', function () { + it('covers authenticated', async function () { + service.authenticator.sessionRequiredLocal.resolves(true); + await service.handlerGetAdminSettings(req, res, ctx); + assert(service.sessionManager.getAdminSettings.called); + }); + it('covers unauthenticated', async function () { + service.authenticator.sessionRequiredLocal.resolves(false); + await service.handlerGetAdminSettings(req, res, ctx); + assert(service.sessionManager.getAdminSettings.notCalled); + }); + }); // handlerGetAdminSettings + + describe('handlerPostAdminSettings', function () { + it('covers authenticated', async function () { + service.authenticator.sessionRequiredLocal.resolves(true); + await service.handlerPostAdminSettings(req, res, ctx); + assert(service.sessionManager.postAdminSettings.called); + }); + it('covers unauthenticated', async function () { + service.authenticator.sessionRequiredLocal.resolves(false); + await service.handlerPostAdminSettings(req, res, ctx); + assert(service.sessionManager.postAdminSettings.notCalled); + }); + }); // handlerPostAdminSettings + describe('handlerGetAdmin', function () { it('covers authenticated', async function () { service.authenticator.sessionRequiredLocal.resolves(true); @@ -297,4 +321,4 @@ describe('Service', function () { }); }); // handlerWhaGwan -}); \ No newline at end of file +});