aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/shared/mock-servers/mock-proxy.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/shared/mock-servers/mock-proxy.ts')
-rw-r--r--server/tests/shared/mock-servers/mock-proxy.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/server/tests/shared/mock-servers/mock-proxy.ts b/server/tests/shared/mock-servers/mock-proxy.ts
new file mode 100644
index 000000000..cbc7c4466
--- /dev/null
+++ b/server/tests/shared/mock-servers/mock-proxy.ts
@@ -0,0 +1,24 @@
1import { createServer, Server } from 'http'
2import proxy from 'proxy'
3import { getPort, terminateServer } from './shared'
4
5class MockProxy {
6 private server: Server
7
8 initialize () {
9 return new Promise<number>(res => {
10 this.server = proxy(createServer())
11 this.server.listen(0, () => res(getPort(this.server)))
12 })
13 }
14
15 terminate () {
16 return terminateServer(this.server)
17 }
18}
19
20// ---------------------------------------------------------------------------
21
22export {
23 MockProxy
24}