Move email code to src/email/
This commit is contained in:
@@ -5,15 +5,16 @@ require('co-mocha')(require('mocha')); // monkey patch mocha for generators
|
||||
const expect = require('chai').expect;
|
||||
const log = require('npmlog');
|
||||
const config = require('config');
|
||||
const Email = require('../../src/dao/email');
|
||||
const Email = require('../../src/email/email');
|
||||
const nodemailer = require('nodemailer');
|
||||
const tpl = require('../../src/email/templates.json');
|
||||
|
||||
log.level = config.log.level;
|
||||
|
||||
describe('Email Integration Tests', function() {
|
||||
this.timeout(20000);
|
||||
|
||||
let email, credentials;
|
||||
let email, credentials, userId, origin;
|
||||
|
||||
before(() => {
|
||||
try {
|
||||
@@ -23,6 +24,16 @@ describe('Email Integration Tests', function() {
|
||||
this.skip();
|
||||
return;
|
||||
}
|
||||
userId = {
|
||||
name: credentials.sender.name,
|
||||
email: credentials.sender.email,
|
||||
keyid: '0123456789ABCDF0',
|
||||
nonce: 'qwertzuioasdfghjkqwertzuio'
|
||||
};
|
||||
origin = {
|
||||
protocol: 'http',
|
||||
host: 'localhost:' + config.server.port
|
||||
};
|
||||
email = new Email(nodemailer);
|
||||
email.init({
|
||||
host: process.env.SMTP_HOST || credentials.smtp.host,
|
||||
@@ -37,7 +48,7 @@ describe('Email Integration Tests', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("send", () => {
|
||||
describe("_sendHelper", () => {
|
||||
it('should work', function *() {
|
||||
let mailOptions = {
|
||||
from: credentials.sender,
|
||||
@@ -46,27 +57,20 @@ describe('Email Integration Tests', function() {
|
||||
text: 'Hello world 🐴', // plaintext body
|
||||
html: '<b>Hello world 🐴</b>' // html body
|
||||
};
|
||||
let info = yield email.send(mailOptions);
|
||||
let info = yield email._sendHelper(mailOptions);
|
||||
expect(info).to.exist;
|
||||
});
|
||||
});
|
||||
|
||||
describe("sendVerifyKey", () => {
|
||||
describe("send verifyKey template", () => {
|
||||
it('should work', function *() {
|
||||
let options = {
|
||||
userIds: [{
|
||||
name: credentials.sender.name,
|
||||
email: credentials.sender.email,
|
||||
keyid: '0123456789ABCDF0',
|
||||
nonce: 'qwertzuioasdfghjkqwertzuio'
|
||||
}],
|
||||
primaryEmail: credentials.sender.email,
|
||||
origin: {
|
||||
protocol: 'http',
|
||||
host: 'localhost:' + config.server.port
|
||||
}
|
||||
};
|
||||
yield email.sendVerifyKey(options);
|
||||
yield email.send({ template:tpl.verifyKey, userId, origin });
|
||||
});
|
||||
});
|
||||
|
||||
describe("send verifyRemove template", () => {
|
||||
it('should work', function *() {
|
||||
yield email.send({ template:tpl.verifyRemove, userId, origin });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user