mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-02 07:43:11 +03:00
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:
parent
df4df2a4aa
commit
158652b117
@ -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 () {
|
||||
|
Loading…
Reference in New Issue
Block a user