diff options
Diffstat (limited to 'shared/extra-utils/mock-servers/utils.ts')
-rw-r--r-- | shared/extra-utils/mock-servers/utils.ts | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/shared/extra-utils/mock-servers/utils.ts b/shared/extra-utils/mock-servers/utils.ts deleted file mode 100644 index 235642439..000000000 --- a/shared/extra-utils/mock-servers/utils.ts +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | import { Express } from 'express' | ||
2 | import { Server } from 'http' | ||
3 | import { AddressInfo } from 'net' | ||
4 | |||
5 | function randomListen (app: Express) { | ||
6 | return new Promise<Server>(res => { | ||
7 | const server = app.listen(0, () => res(server)) | ||
8 | }) | ||
9 | } | ||
10 | |||
11 | function getPort (server: Server) { | ||
12 | const address = server.address() as AddressInfo | ||
13 | |||
14 | return address.port | ||
15 | } | ||
16 | |||
17 | function terminateServer (server: Server) { | ||
18 | if (!server) return Promise.resolve() | ||
19 | |||
20 | return new Promise<void>((res, rej) => { | ||
21 | server.close(err => { | ||
22 | if (err) return rej(err) | ||
23 | |||
24 | return res() | ||
25 | }) | ||
26 | }) | ||
27 | } | ||
28 | |||
29 | export { | ||
30 | randomListen, | ||
31 | getPort, | ||
32 | terminateServer | ||
33 | } | ||