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/index.ts | 1 + shared/extra-utils/plugins/mock-blocklist.ts | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 shared/extra-utils/plugins/mock-blocklist.ts (limited to 'shared') diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts index fd8fef5dc..d3f010b20 100644 --- a/shared/extra-utils/index.ts +++ b/shared/extra-utils/index.ts @@ -27,3 +27,4 @@ export * from './videos/video-change-ownership' export * from './feeds/feeds' export * from './instances-index/mock-instances-index' export * from './search/videos' +export * from './plugins/mock-blocklist' 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