1
0
Fork 0
peertube/server/tests/shared/mock-servers/mock-proxy.ts
2021-12-17 12:24:03 +01:00

24 lines
507 B
TypeScript

import { createServer, Server } from 'http'
import proxy from 'proxy'
import { getPort, terminateServer } from './shared'
class MockProxy {
private server: Server
initialize () {
return new Promise<number>(res => {
this.server = proxy(createServer())
this.server.listen(0, () => res(getPort(this.server)))
})
}
terminate () {
return terminateServer(this.server)
}
}
// ---------------------------------------------------------------------------
export {
MockProxy
}