Close mock blocklit server when tests end
This commit is contained in:
parent
84f6e32c7b
commit
7820a54e5e
3 changed files with 11 additions and 1 deletions
|
@ -185,6 +185,8 @@ describe('Official plugin auto-block videos', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
await blocklistServer.terminate()
|
||||||
|
|
||||||
await cleanupTests(servers)
|
await cleanupTests(servers)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -238,6 +238,8 @@ describe('Official plugin auto-mute', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
await blocklistServer.terminate()
|
||||||
|
|
||||||
await cleanupTests(servers)
|
await cleanupTests(servers)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import * as express from 'express'
|
import * as express from 'express'
|
||||||
|
import { Server } from 'http'
|
||||||
|
|
||||||
type BlocklistResponse = {
|
type BlocklistResponse = {
|
||||||
data: {
|
data: {
|
||||||
|
@ -10,6 +11,7 @@ type BlocklistResponse = {
|
||||||
|
|
||||||
export class MockBlocklist {
|
export class MockBlocklist {
|
||||||
private body: BlocklistResponse
|
private body: BlocklistResponse
|
||||||
|
private server: Server
|
||||||
|
|
||||||
initialize () {
|
initialize () {
|
||||||
return new Promise(res => {
|
return new Promise(res => {
|
||||||
|
@ -19,11 +21,15 @@ export class MockBlocklist {
|
||||||
return res.json(this.body)
|
return res.json(this.body)
|
||||||
})
|
})
|
||||||
|
|
||||||
app.listen(42100, () => res())
|
this.server = app.listen(42100, () => res())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
replace (body: BlocklistResponse) {
|
replace (body: BlocklistResponse) {
|
||||||
this.body = body
|
this.body = body
|
||||||
}
|
}
|
||||||
|
|
||||||
|
terminate () {
|
||||||
|
if (this.server) this.server.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue