From aff6d20f9fde477f7b97e2509bbf751cd4a15011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 11 May 2023 19:01:28 -0400 Subject: [PATCH] test: fix digest test --- src/user/digest.js | 1 + test/user.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/user/digest.js b/src/user/digest.js index a40be0ee0d..4a62313c6d 100644 --- a/src/user/digest.js +++ b/src/user/digest.js @@ -140,6 +140,7 @@ Digest.send = async function (data) { batch: 100, }); winston.info(`[user/jobs] Digest (${data.interval}) sending completed. ${emailsSent} emails sent.`); + return emailsSent; }; Digest.getDeliveryTimes = async (start, stop) => { diff --git a/test/user.js b/test/user.js index d70da486e9..1c90031474 100644 --- a/test/user.js +++ b/test/user.js @@ -1493,7 +1493,9 @@ describe('User', () => { it('should send digests', async () => { const oldValue = meta.config.includeUnverifiedEmails; meta.config.includeUnverifiedEmails = true; - const uid = await User.create({ username: 'digest', email: 'email@test.com' }); + const uid = await User.create({ username: 'digest' }); + await User.setUserField(uid, 'email', 'email@test.com'); + await User.email.confirmByUid(uid); await User.digest.execute({ interval: 'day', subscribers: [uid], @@ -1501,6 +1503,11 @@ describe('User', () => { meta.config.includeUnverifiedEmails = oldValue; }); + it('should return 0', async () => { + const sent = await User.digest.send({ subscribers: [] }); + assert.strictEqual(sent, 0); + }); + it('should not send digests', async () => { await User.digest.execute({ interval: 'month' }); });