]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/plugins/mock-blocklist.ts
Add ability for plugins to specify scale filter
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / plugins / mock-blocklist.ts
index 6fe3dee9f7341e1fedcb74d767c5a68f0bc59e40..50e2289f1eb9090b69f93e7d5a114ef097e7d322 100644 (file)
@@ -1,4 +1,5 @@
 import * as express from 'express'
+import { Server } from 'http'
 
 type BlocklistResponse = {
   data: {
@@ -10,20 +11,25 @@ type BlocklistResponse = {
 
 export class MockBlocklist {
   private body: BlocklistResponse
+  private server: Server
 
   initialize () {
-    return new Promise(res => {
+    return new Promise<void>(res => {
       const app = express()
 
       app.get('/blocklist', (req: express.Request, res: express.Response) => {
         return res.json(this.body)
       })
 
-      app.listen(42100, () => res())
+      this.server = app.listen(42100, () => res())
     })
   }
 
   replace (body: BlocklistResponse) {
     this.body = body
   }
+
+  terminate () {
+    if (this.server) this.server.close()
+  }
 }