mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +03:00
e91e9eadac
no issue - in preparation for subscribers V2 - do not implement code in index.js - create mail utils
46 lines
1.2 KiB
JavaScript
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);
|
|
});
|
|
});
|