From 7820a54e5e168195e58209a4051dd5ecbbec93cf Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 26 Jun 2020 14:50:40 +0200 Subject: Close mock blocklit server when tests end --- shared/extra-utils/plugins/mock-blocklist.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'shared/extra-utils/plugins') diff --git a/shared/extra-utils/plugins/mock-blocklist.ts b/shared/extra-utils/plugins/mock-blocklist.ts index 6fe3dee9f..07c8c5122 100644 --- a/shared/extra-utils/plugins/mock-blocklist.ts +++ b/shared/extra-utils/plugins/mock-blocklist.ts @@ -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() + } } -- cgit v1.2.3