Close mock blocklit server when tests end

pull/2904/head
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

@ -185,6 +185,8 @@ describe('Official plugin auto-block videos', function () {
})
after(async function () {
await blocklistServer.terminate()
await cleanupTests(servers)
})
})

View File

@ -238,6 +238,8 @@ describe('Official plugin auto-mute', function () {
})
after(async function () {
await blocklistServer.terminate()
await cleanupTests(servers)
})
})

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()
}
}