]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/mock-servers/mock-plugin-blocklist.ts
Add peertube short link import test
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / mock-servers / mock-plugin-blocklist.ts
index d18f8224ff6382a9ce113e350ebf59b141a53eff..344d4bdbb7d7dca5d7d20949cd792b1189b1e355 100644 (file)
@@ -1,6 +1,7 @@
-import * as express from 'express'
+import express, { Request, Response } from 'express'
 import { Server } from 'http'
 import { randomInt } from '@shared/core-utils'
+import { terminateServer } from './utils'
 
 type BlocklistResponse = {
   data: {
@@ -18,11 +19,11 @@ export class MockBlocklist {
     return new Promise<number>(res => {
       const app = express()
 
-      app.get('/blocklist', (req: express.Request, res: express.Response) => {
+      app.get('/blocklist', (req: Request, res: Response) => {
         return res.json(this.body)
       })
 
-      const port = 42201 + randomInt(1, 100)
+      const port = 45000 + randomInt(1, 1000)
       this.server = app.listen(port, () => res(port))
     })
   }
@@ -32,6 +33,6 @@ export class MockBlocklist {
   }
 
   terminate () {
-    if (this.server) this.server.close()
+    return terminateServer(this.server)
   }
 }