diff options
Diffstat (limited to 'server/tests/shared/mock-servers')
-rw-r--r-- | server/tests/shared/mock-servers/mock-email.ts | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/server/tests/shared/mock-servers/mock-email.ts b/server/tests/shared/mock-servers/mock-email.ts index c518679c9..79bc22d58 100644 --- a/server/tests/shared/mock-servers/mock-email.ts +++ b/server/tests/shared/mock-servers/mock-email.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | import { ChildProcess } from 'child_process' | ||
2 | import MailDev from '@peertube/maildev' | 1 | import MailDev from '@peertube/maildev' |
3 | import { parallelTests, randomInt } from '@shared/core-utils' | 2 | import { parallelTests, randomInt } from '@shared/core-utils' |
4 | 3 | ||
@@ -6,7 +5,7 @@ class MockSmtpServer { | |||
6 | 5 | ||
7 | private static instance: MockSmtpServer | 6 | private static instance: MockSmtpServer |
8 | private started = false | 7 | private started = false |
9 | private emailChildProcess: ChildProcess | 8 | private maildev: any |
10 | private emails: object[] | 9 | private emails: object[] |
11 | 10 | ||
12 | private constructor () { } | 11 | private constructor () { } |
@@ -20,18 +19,18 @@ class MockSmtpServer { | |||
20 | return res(undefined) | 19 | return res(undefined) |
21 | } | 20 | } |
22 | 21 | ||
23 | const maildev = new MailDev({ | 22 | this.maildev = new MailDev({ |
24 | ip: '127.0.0.1', | 23 | ip: '127.0.0.1', |
25 | smtp: port, | 24 | smtp: port, |
26 | disableWeb: true, | 25 | disableWeb: true, |
27 | silent: true | 26 | silent: true |
28 | }) | 27 | }) |
29 | 28 | ||
30 | maildev.on('new', email => { | 29 | this.maildev.on('new', email => { |
31 | this.emails.push(email) | 30 | this.emails.push(email) |
32 | }) | 31 | }) |
33 | 32 | ||
34 | maildev.listen(err => { | 33 | this.maildev.listen(err => { |
35 | if (err) return rej(err) | 34 | if (err) return rej(err) |
36 | 35 | ||
37 | this.started = true | 36 | this.started = true |
@@ -42,11 +41,11 @@ class MockSmtpServer { | |||
42 | } | 41 | } |
43 | 42 | ||
44 | kill () { | 43 | kill () { |
45 | if (!this.emailChildProcess) return | 44 | if (!this.maildev) return |
46 | 45 | ||
47 | process.kill(this.emailChildProcess.pid) | 46 | this.maildev.shutdown() |
48 | 47 | ||
49 | this.emailChildProcess = null | 48 | this.maildev = null |
50 | MockSmtpServer.instance = null | 49 | MockSmtpServer.instance = null |
51 | } | 50 | } |
52 | 51 | ||