aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/plugins/mock-blocklist.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-06-26 14:50:40 +0200
committerChocobozzz <me@florianbigard.com>2020-06-26 14:51:01 +0200
commit7820a54e5e168195e58209a4051dd5ecbbec93cf (patch)
treebeb0d7a0181424442775639851f4d9d7a8afcb79 /shared/extra-utils/plugins/mock-blocklist.ts
parent84f6e32c7be4098c08e8735825ce1bcb44e43193 (diff)
downloadPeerTube-7820a54e5e168195e58209a4051dd5ecbbec93cf.tar.gz
PeerTube-7820a54e5e168195e58209a4051dd5ecbbec93cf.tar.zst
PeerTube-7820a54e5e168195e58209a4051dd5ecbbec93cf.zip
Close mock blocklit server when tests end
Diffstat (limited to 'shared/extra-utils/plugins/mock-blocklist.ts')
-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}