1 import MailDev from '@peertube/maildev'
2 import { parallelTests, randomInt } from '@shared/core-utils'
6 private static instance: MockSmtpServer
7 private started = false
9 private emails: object[]
11 private constructor () { }
13 collectEmails (emailsCollection: object[]) {
14 return new Promise<number>((res, rej) => {
15 const port = parallelTests() ? randomInt(1025, 2000) : 1025
16 this.emails = emailsCollection
22 this.maildev = new MailDev({
29 this.maildev.on('new', email => {
30 this.emails.push(email)
33 this.maildev.listen(err => {
34 if (err) return rej(err)
44 if (!this.maildev) return
49 MockSmtpServer.instance = null
52 static get Instance () {
53 return this.instance || (this.instance = new this())
57 // ---------------------------------------------------------------------------