fix typechecking in test/server.js

This commit is contained in:
Zack Schuster 2018-07-06 13:31:11 -07:00
parent 0ca71c4c9c
commit ba41892117
2 changed files with 13 additions and 3 deletions

View File

@ -318,4 +318,9 @@ class Client {
}
exports.Client = Client;
/**
* @param {SMTPOptions} server smtp options
* @returns {Client} the client
*/
exports.connect = server => new Client(server);

View File

@ -1,18 +1,23 @@
const path = require('path');
const assert = require('assert');
describe('Connect to wrong email server', function() {
const emailModulePath = require.resolve(path.join(__dirname, '..', 'email'));
const emailModulePath = require.resolve('../email.js');
/**
* @type {typeof import('../email.js')}
*/
let email = null;
beforeEach(function() {
if (require.cache[emailModulePath]) {
delete require.cache[emailModulePath];
}
email = require(emailModulePath);
});
it('Should not call callback multiple times with wrong server configuration', function(done) {
this.timeout(5000);
const server = require(emailModulePath).server.connect({ host: 'bar.baz' });
const server = email.server.connect({ host: 'bar.baz' });
server.send(
{
from: 'foo@bar.baz',