diff options
Diffstat (limited to 'shared/extra-utils/mock-servers/utils.ts')
-rw-r--r-- | shared/extra-utils/mock-servers/utils.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/shared/extra-utils/mock-servers/utils.ts b/shared/extra-utils/mock-servers/utils.ts new file mode 100644 index 000000000..64d94c868 --- /dev/null +++ b/shared/extra-utils/mock-servers/utils.ts | |||
@@ -0,0 +1,17 @@ | |||
1 | import { Server } from 'http' | ||
2 | |||
3 | function terminateServer (server: Server) { | ||
4 | if (!server) return Promise.resolve() | ||
5 | |||
6 | return new Promise<void>((res, rej) => { | ||
7 | server.close(err => { | ||
8 | if (err) return rej(err) | ||
9 | |||
10 | return res() | ||
11 | }) | ||
12 | }) | ||
13 | } | ||
14 | |||
15 | export { | ||
16 | terminateServer | ||
17 | } | ||