1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | Object.defineProperty(exports, "__esModule", { value: true });
|
7 | exports.createRestAppClient = exports.createClientForHandler = exports.supertest = void 0;
|
8 | const tslib_1 = require("tslib");
|
9 |
|
10 |
|
11 |
|
12 | const http_1 = tslib_1.__importDefault(require("http"));
|
13 | const supertest_1 = tslib_1.__importDefault(require("supertest"));
|
14 | exports.supertest = supertest_1.default;
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | function createClientForHandler(handler) {
|
21 | const server = http_1.default.createServer(handler);
|
22 | return (0, supertest_1.default)(server);
|
23 | }
|
24 | exports.createClientForHandler = createClientForHandler;
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | function createRestAppClient(app) {
|
32 | var _a;
|
33 | const url = (_a = app.restServer.rootUrl) !== null && _a !== void 0 ? _a : app.restServer.url;
|
34 | if (!url) {
|
35 | throw new Error(`Cannot create client for ${app.constructor.name}, it is not listening.`);
|
36 | }
|
37 | return (0, supertest_1.default)(url);
|
38 | }
|
39 | exports.createRestAppClient = createRestAppClient;
|
40 |
|
\ | No newline at end of file |