diff options
Diffstat (limited to 'client/e2e/src/utils/mock-smtp.ts')
-rw-r--r-- | client/e2e/src/utils/mock-smtp.ts | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/client/e2e/src/utils/mock-smtp.ts b/client/e2e/src/utils/mock-smtp.ts index 614477d7d..be6f8b259 100644 --- a/client/e2e/src/utils/mock-smtp.ts +++ b/client/e2e/src/utils/mock-smtp.ts | |||
@@ -1,11 +1,10 @@ | |||
1 | import { ChildProcess } from 'child_process' | ||
2 | import MailDev from '@peertube/maildev' | 1 | import MailDev from '@peertube/maildev' |
3 | 2 | ||
4 | class MockSMTPServer { | 3 | class MockSMTPServer { |
5 | 4 | ||
6 | private static instance: MockSMTPServer | 5 | private static instance: MockSMTPServer |
7 | private started = false | 6 | private started = false |
8 | private emailChildProcess: ChildProcess | 7 | private maildev: any |
9 | private emails: object[] | 8 | private emails: object[] |
10 | 9 | ||
11 | collectEmails (port: number, emailsCollection: object[]) { | 10 | collectEmails (port: number, emailsCollection: object[]) { |
@@ -16,18 +15,20 @@ class MockSMTPServer { | |||
16 | return res(undefined) | 15 | return res(undefined) |
17 | } | 16 | } |
18 | 17 | ||
19 | const maildev = new MailDev({ | 18 | this.maildev = new MailDev({ |
20 | ip: '127.0.0.1', | 19 | ip: '127.0.0.1', |
21 | smtp: port, | 20 | smtp: port, |
22 | disableWeb: true, | 21 | disableWeb: true, |
23 | silent: true | 22 | silent: true |
24 | }) | 23 | }) |
25 | 24 | ||
26 | maildev.on('new', email => { | 25 | this.maildev.on('new', email => { |
27 | this.emails.push(email) | 26 | this.emails.push(email) |
27 | |||
28 | console.log('pushed email', email) | ||
28 | }) | 29 | }) |
29 | 30 | ||
30 | maildev.listen(err => { | 31 | this.maildev.listen(err => { |
31 | if (err) return rej(err) | 32 | if (err) return rej(err) |
32 | 33 | ||
33 | this.started = true | 34 | this.started = true |
@@ -38,11 +39,11 @@ class MockSMTPServer { | |||
38 | } | 39 | } |
39 | 40 | ||
40 | kill () { | 41 | kill () { |
41 | if (!this.emailChildProcess) return | 42 | if (!this.maildev) return |
42 | 43 | ||
43 | process.kill(this.emailChildProcess.pid) | 44 | this.maildev.close() |
44 | 45 | ||
45 | this.emailChildProcess = null | 46 | this.maildev = null |
46 | MockSMTPServer.instance = null | 47 | MockSMTPServer.instance = null |
47 | } | 48 | } |
48 | 49 | ||