Fix eslint errors
This commit is contained in:
@@ -5,28 +5,29 @@ const Email = require('../../src/email/email');
|
||||
const nodemailer = require('nodemailer');
|
||||
|
||||
describe('Email Unit Tests', () => {
|
||||
let email, sendFnStub;
|
||||
let email;
|
||||
let sendFnStub;
|
||||
|
||||
let template = {
|
||||
const template = {
|
||||
subject: 'foo',
|
||||
text: 'bar',
|
||||
html: '<strong>bar</strong>'
|
||||
};
|
||||
let sender = {
|
||||
const sender = {
|
||||
name: 'Foo Bar',
|
||||
email: 'foo@bar.com'
|
||||
};
|
||||
let userId1 = {
|
||||
const userId1 = {
|
||||
name: 'name1',
|
||||
email: 'email1',
|
||||
nonce: 'qwertzuioasdfghjkqwertzuio'
|
||||
};
|
||||
let keyId = '0123456789ABCDF0';
|
||||
let origin = {
|
||||
const keyId = '0123456789ABCDF0';
|
||||
const origin = {
|
||||
protocol: 'http',
|
||||
host: 'localhost:8888'
|
||||
};
|
||||
let mailOptions = {
|
||||
const mailOptions = {
|
||||
from: sender,
|
||||
to: sender,
|
||||
subject: 'Hello ✔', // Subject line
|
||||
@@ -37,7 +38,7 @@ describe('Email Unit Tests', () => {
|
||||
beforeEach(() => {
|
||||
sendFnStub = sinon.stub();
|
||||
sinon.stub(nodemailer, 'createTransport').returns({
|
||||
templateSender: () => { return sendFnStub; }
|
||||
templateSender: () => sendFnStub
|
||||
});
|
||||
|
||||
sinon.stub(log, 'warn');
|
||||
@@ -46,8 +47,8 @@ describe('Email Unit Tests', () => {
|
||||
email = new Email(nodemailer);
|
||||
email.init({
|
||||
host: 'host',
|
||||
auth: { user:'user', pass:'pass' },
|
||||
sender: sender
|
||||
auth: {user: 'user', pass: 'pass'},
|
||||
sender
|
||||
});
|
||||
expect(email._sender).to.equal(sender);
|
||||
});
|
||||
@@ -60,7 +61,7 @@ describe('Email Unit Tests', () => {
|
||||
|
||||
describe("send", () => {
|
||||
beforeEach(() => {
|
||||
sinon.stub(email, '_sendHelper').returns(Promise.resolve({ response:'250' }));
|
||||
sinon.stub(email, '_sendHelper').returns(Promise.resolve({response: '250'}));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -68,7 +69,7 @@ describe('Email Unit Tests', () => {
|
||||
});
|
||||
|
||||
it('should work', function *() {
|
||||
let info = yield email.send({ template, userId:userId1, keyId, origin});
|
||||
const info = yield email.send({template, userId: userId1, keyId, origin});
|
||||
|
||||
expect(info.response).to.match(/^250/);
|
||||
});
|
||||
@@ -76,17 +77,17 @@ describe('Email Unit Tests', () => {
|
||||
|
||||
describe("_sendHelper", () => {
|
||||
it('should work', function *() {
|
||||
sendFnStub.returns(Promise.resolve({ response:'250' }));
|
||||
sendFnStub.returns(Promise.resolve({response: '250'}));
|
||||
|
||||
let info = yield email._sendHelper(mailOptions);
|
||||
const info = yield email._sendHelper(mailOptions);
|
||||
|
||||
expect(info.response).to.match(/^250/);
|
||||
});
|
||||
|
||||
it('should log warning for reponse error', function *() {
|
||||
sendFnStub.returns(Promise.resolve({ response:'554' }));
|
||||
sendFnStub.returns(Promise.resolve({response: '554'}));
|
||||
|
||||
let info = yield email._sendHelper(mailOptions);
|
||||
const info = yield email._sendHelper(mailOptions);
|
||||
|
||||
expect(info.response).to.match(/^554/);
|
||||
expect(log.warn.calledOnce).to.be.true;
|
||||
@@ -97,12 +98,11 @@ describe('Email Unit Tests', () => {
|
||||
|
||||
try {
|
||||
yield email._sendHelper(mailOptions);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
expect(log.error.calledOnce).to.be.true;
|
||||
expect(e.status).to.equal(500);
|
||||
expect(e.message).to.match(/failed/);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user