1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Close mock blocklit server when tests end

This commit is contained in:
Chocobozzz 2020-06-26 14:50:40 +02:00
parent 84f6e32c7b
commit 7820a54e5e
No known key found for this signature in database
GPG key ID: 583A612D890159BE
3 changed files with 11 additions and 1 deletions

View file

@ -1,4 +1,5 @@
import * as express from 'express'
import { Server } from 'http'
type BlocklistResponse = {
data: {
@ -10,6 +11,7 @@ type BlocklistResponse = {
export class MockBlocklist {
private body: BlocklistResponse
private server: Server
initialize () {
return new Promise(res => {
@ -19,11 +21,15 @@ export class MockBlocklist {
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()
}
}