From 8bff1fe009b555434c41bde361fddbb484329bae Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 7 May 2020 16:32:54 +0200 Subject: Add auto mute plugin tests --- shared/extra-utils/plugins/mock-blocklist.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 shared/extra-utils/plugins/mock-blocklist.ts (limited to 'shared/extra-utils/plugins') diff --git a/shared/extra-utils/plugins/mock-blocklist.ts b/shared/extra-utils/plugins/mock-blocklist.ts new file mode 100644 index 000000000..ef57d96a8 --- /dev/null +++ b/shared/extra-utils/plugins/mock-blocklist.ts @@ -0,0 +1,28 @@ +import * as express from 'express' + +type BlocklistResponse = { + data: { + value: string + action?: 'add' | 'remove' + }[] +} + +export class MockBlocklist { + private body: BlocklistResponse + + initialize () { + return new Promise(res => { + const app = express() + + app.get('/blocklist', (req: express.Request, res: express.Response) => { + return res.json(this.body) + }) + + app.listen(42100, () => res()) + }) + } + + replace (body: BlocklistResponse) { + this.body = body + } +} -- cgit v1.2.3