diff options
author | Chocobozzz <me@florianbigard.com> | 2020-05-07 16:32:54 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-05-07 16:34:09 +0200 |
commit | 8bff1fe009b555434c41bde361fddbb484329bae (patch) | |
tree | 7cde77c0e8481f8d382b4bf43dc6bd676cf10228 /shared/extra-utils | |
parent | faf174d043ccd9d67b0ac98d011cabdbb7b21e76 (diff) | |
download | PeerTube-8bff1fe009b555434c41bde361fddbb484329bae.tar.gz PeerTube-8bff1fe009b555434c41bde361fddbb484329bae.tar.zst PeerTube-8bff1fe009b555434c41bde361fddbb484329bae.zip |
Add auto mute plugin tests
Diffstat (limited to 'shared/extra-utils')
-rw-r--r-- | shared/extra-utils/index.ts | 1 | ||||
-rw-r--r-- | shared/extra-utils/plugins/mock-blocklist.ts | 28 |
2 files changed, 29 insertions, 0 deletions
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' | |||
27 | export * from './feeds/feeds' | 27 | export * from './feeds/feeds' |
28 | export * from './instances-index/mock-instances-index' | 28 | export * from './instances-index/mock-instances-index' |
29 | export * from './search/videos' | 29 | export * from './search/videos' |
30 | 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 @@ | |||
1 | import * as express from 'express' | ||
2 | |||
3 | type BlocklistResponse = { | ||
4 | data: { | ||
5 | value: string | ||
6 | action?: 'add' | 'remove' | ||
7 | }[] | ||
8 | } | ||
9 | |||
10 | export class MockBlocklist { | ||
11 | private body: BlocklistResponse | ||
12 | |||
13 | initialize () { | ||
14 | return new Promise(res => { | ||
15 | const app = express() | ||
16 | |||
17 | app.get('/blocklist', (req: express.Request, res: express.Response) => { | ||
18 | return res.json(this.body) | ||
19 | }) | ||
20 | |||
21 | app.listen(42100, () => res()) | ||
22 | }) | ||
23 | } | ||
24 | |||
25 | replace (body: BlocklistResponse) { | ||
26 | this.body = body | ||
27 | } | ||
28 | } | ||