smtp/connection: fix custom log fn assignment

This commit is contained in:
Zack Schuster 2022-04-26 19:14:14 -07:00
parent 9a5ce38186
commit 4f45799a3e
2 changed files with 12 additions and 1 deletions

View File

@ -183,7 +183,7 @@ export class SMTPConnection extends EventEmitter {
this.password = () => password as string;
if (typeof logger === 'function') {
this.log = log;
this.log = logger;
}
}

11
test/connection.ts Normal file
View File

@ -0,0 +1,11 @@
import test from 'ava';
import { SMTPConnection } from '../email.js';
test('accepts a custom logger', async (t) => {
const logger = () => {
/** ø */
};
const connection = new SMTPConnection({ logger });
t.is(Reflect.get(connection, 'log'), logger);
});