Refactored and fixed GhostMailer unit tests

refs a1556797b6

- 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
This commit is contained in:
Naz 2021-05-27 13:14:30 +04:00
parent df4df2a4aa
commit 158652b117

View File

@ -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 () {