aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/plugins/mock-blocklist.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/shared/extra-utils/plugins/mock-blocklist.ts b/shared/extra-utils/plugins/mock-blocklist.ts
index 6fe3dee9f..07c8c5122 100644
--- a/shared/extra-utils/plugins/mock-blocklist.ts
+++ b/shared/extra-utils/plugins/mock-blocklist.ts
@@ -1,4 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { Server } from 'http'
2 3
3type BlocklistResponse = { 4type BlocklistResponse = {
4 data: { 5 data: {
@@ -10,6 +11,7 @@ type BlocklistResponse = {
10 11
11export class MockBlocklist { 12export class MockBlocklist {
12 private body: BlocklistResponse 13 private body: BlocklistResponse
14 private server: Server
13 15
14 initialize () { 16 initialize () {
15 return new Promise(res => { 17 return new Promise(res => {
@@ -19,11 +21,15 @@ export class MockBlocklist {
19 return res.json(this.body) 21 return res.json(this.body)
20 }) 22 })
21 23
22 app.listen(42100, () => res()) 24 this.server = app.listen(42100, () => res())
23 }) 25 })
24 } 26 }
25 27
26 replace (body: BlocklistResponse) { 28 replace (body: BlocklistResponse) {
27 this.body = body 29 this.body = body
28 } 30 }
31
32 terminate () {
33 if (this.server) this.server.close()
34 }
29} 35}