Ghost/core/test/unit/mail/utils_spec.js
Katharina Irrgang e91e9eadac improvement: mail structure (#7033)
no issue
- in preparation for subscribers V2
- do not implement code in index.js
- create mail utils
2016-06-28 20:13:01 +02:00

46 lines
1.2 KiB
JavaScript

var sinon = require('sinon'),
mail = require(__dirname + '../../../../server/mail'),
sandbox = sinon.sandbox.create();
describe('Mail: Utils', function () {
var scope = {ghostMailer: null};
before(function () {
scope.ghostMailer = new mail.GhostMailer();
sandbox.stub(scope.ghostMailer.transport, 'sendMail', function (message, sendMailDone) {
sendMailDone(null, {
statusHandler: {
once: function (eventName, eventDone) {
if (eventName === 'sent') {
eventDone();
}
}
}
});
});
});
after(function () {
sandbox.restore();
});
it('generate welcome', function (done) {
mail.utils.generateContent({
template: 'welcome',
data: {
ownerEmail: 'kate@ghost.org'
}
}).then(function (result) {
return scope.ghostMailer.send({
to: 'kate@ghost.org',
subject: 'lol',
html: result.html,
text: result.text
});
}).then(function () {
done();
}).catch(done);
});
});