mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 05:42:43 +00:00
40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
//#FILE: test-http2-misc-util.js
|
|
//#SHA1: 0fa21e185faeff6ee5b1d703d9a998bf98d6b229
|
|
//-----------------
|
|
const http2 = require('http2');
|
|
|
|
describe('HTTP/2 Misc Util', () => {
|
|
test('HTTP2 constants are defined', () => {
|
|
expect(http2.constants).toBeDefined();
|
|
expect(http2.constants.NGHTTP2_SESSION_SERVER).toBe(0);
|
|
expect(http2.constants.NGHTTP2_SESSION_CLIENT).toBe(1);
|
|
});
|
|
|
|
test('HTTP2 default settings are within valid ranges', () => {
|
|
const defaultSettings = http2.getDefaultSettings();
|
|
expect(defaultSettings).toBeDefined();
|
|
expect(defaultSettings.headerTableSize).toBeGreaterThanOrEqual(0);
|
|
expect(defaultSettings.enablePush).toBe(true);
|
|
expect(defaultSettings.initialWindowSize).toBeGreaterThanOrEqual(0);
|
|
expect(defaultSettings.maxFrameSize).toBeGreaterThanOrEqual(16384);
|
|
expect(defaultSettings.maxConcurrentStreams).toBeGreaterThanOrEqual(0);
|
|
expect(defaultSettings.maxHeaderListSize).toBeGreaterThanOrEqual(0);
|
|
});
|
|
|
|
test('HTTP2 getPackedSettings and getUnpackedSettings', () => {
|
|
const settings = {
|
|
headerTableSize: 4096,
|
|
enablePush: true,
|
|
initialWindowSize: 65535,
|
|
maxFrameSize: 16384,
|
|
};
|
|
const packed = http2.getPackedSettings(settings);
|
|
expect(packed).toBeInstanceOf(Buffer);
|
|
|
|
const unpacked = http2.getUnpackedSettings(packed);
|
|
expect(unpacked).toEqual(expect.objectContaining(settings));
|
|
});
|
|
});
|
|
|
|
//<#END_FILE: test-http2-misc-util.js
|