Skip to content

Commit 28b8b5e

Browse files
committed
test(http-server): add http2 integration tests
Signed-off-by: Rifa Achrinza <[email protected]>
1 parent ef72b29 commit 28b8b5e

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

packages/http-server/src/__tests__/integration/http-server.integration.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import {
77
expect,
88
givenHttpServerConfig,
9+
Http2sOptions,
910
httpGetAsync,
1011
httpsGetAsync,
1112
skipOnTravis,
@@ -18,7 +19,7 @@ import os from 'os';
1819
import pEvent from 'p-event';
1920
import path from 'path';
2021
import {HttpOptions, HttpServer, HttpsOptions} from '../../';
21-
import {HttpServerOptions} from '../../http-server';
22+
import {Http2Options, HttpServerOptions} from '../../http-server';
2223

2324
describe('HttpServer (integration)', () => {
2425
let server: HttpServer | undefined;
@@ -294,6 +295,13 @@ describe('HttpServer (integration)', () => {
294295
}).to.throw(/Named pipe test\.pipe does NOT start with/);
295296
});
296297

298+
it('supports HTTP/2 HTTP', async () => {
299+
const http2Server = givenHttp2Server();
300+
await http2Server.start();
301+
const response = await httpGetAsync(http2Server.url);
302+
expect(response.statusCode).to.equal(200);
303+
});
304+
297305
function getAddressFamily(httpServer: HttpServer) {
298306
if (!httpServer || !httpServer.address) return undefined;
299307
if (typeof httpServer.address === 'string') {
@@ -353,4 +361,25 @@ describe('HttpServer (integration)', () => {
353361
}
354362
return new HttpServer(dummyRequestHandler, options);
355363
}
364+
365+
function givenHttp2Server(): HttpServer {
366+
const options = givenHttpServerConfig<Http2Options>({
367+
protocol: 'http2',
368+
});
369+
370+
return new HttpServer(dummyRequestHandler, options);
371+
}
372+
373+
function givenHttp2sServer({
374+
allowHttp1 = false,
375+
}: {
376+
allowHttp1: boolean;
377+
}): HttpServer {
378+
const options = givenHttpServerConfig<Http2sOptions>({
379+
protocol: 'http2s',
380+
allowHTTP1: allowHttp1,
381+
});
382+
383+
return new HttpServer(dummyRequestHandler, options);
384+
}
356385
});

0 commit comments

Comments
 (0)