From 1b29dbb69d123c35d4fa954b8ee9aa63ded28136 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 13 Feb 2023 12:15:45 -0500 Subject: [PATCH] test: add dummy emailer hook in authentication test --- test/authentication.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/authentication.js b/test/authentication.js index b8889d95eb..3718271809 100644 --- a/test/authentication.js +++ b/test/authentication.js @@ -12,13 +12,22 @@ const db = require('./mocks/databasemock'); const user = require('../src/user'); const utils = require('../src/utils'); const meta = require('../src/meta'); +const plugins = require('../src/plugins'); const privileges = require('../src/privileges'); const helpers = require('./helpers'); describe('authentication', () => { const jar = request.jar(); let regularUid; + const dummyEmailerHook = async (data) => {}; + before((done) => { + // Attach an emailer hook so related requests do not error + plugins.hooks.register('authentication-test', { + hook: 'filter:email.send', + method: dummyEmailerHook, + }); + user.create({ username: 'regular', password: 'regularpwd', email: 'regular@nodebb.org' }, (err, uid) => { assert.ifError(err); regularUid = uid; @@ -27,6 +36,10 @@ describe('authentication', () => { }); }); + after(() => { + plugins.hooks.unregister('authentication-test', 'filter:email.send'); + }); + it('should allow login with email for uid 1', async () => { const oldValue = meta.config.allowLoginWith; meta.config.allowLoginWith = 'username-email';