From 158652b1172e09709a12e2f9e36e74c8f7c2895f Mon Sep 17 00:00:00 2001 From: Naz Date: Thu, 27 May 2021 13:14:30 +0400 Subject: [PATCH] Refactored and fixed GhostMailer unit tests refs https://github.com/TryGhost/Ghost/commit/a1556797b63f5b07c7769ffd7cf5b1b52776b7fb - The test was using an outdated syntax which broke after migration to async/await in the tested funciton - Updated test is much more readable and should handle promise rejections (async function throws) universally --- test/unit/services/mail/GhostMailer_spec.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/test/unit/services/mail/GhostMailer_spec.js b/test/unit/services/mail/GhostMailer_spec.js index eb10777791..22b1b70e51 100644 --- a/test/unit/services/mail/GhostMailer_spec.js +++ b/test/unit/services/mail/GhostMailer_spec.js @@ -105,22 +105,12 @@ describe('Mail: Ghostmailer', function () { }).catch(done); }); - it('should fail to send messages when given insufficient data', function (done) { + it('should fail to send messages when given insufficient data', async function () { mailer = new mail.GhostMailer(); - Promise.all([ - mailer.send().reflect(), - mailer.send({}).reflect(), - mailer.send({subject: '123'}).reflect(), - mailer.send({subject: '', html: '123'}).reflect() - ]).then(function (descriptors) { - descriptors.forEach(function (d) { - d.isFulfilled().should.be.false(); - d.reason().should.be.an.instanceOf(Error); - d.reason().message.should.eql('Incomplete message data.'); - }); - done(); - }).catch(done); + await mailer.send().should.be.rejectedWith('Incomplete message data.'); + await mailer.send({subject: '123'}).should.be.rejectedWith('Incomplete message data.'); + await mailer.send({subject: '', html: '123'}).should.be.rejectedWith('Incomplete message data.'); }); describe('Direct', function () {