Skip to content

Commit 5718c10

Browse files
test(node-http-handler): add test for socketAcquisitionWarningTimeout
1 parent efb27ee commit 5718c10

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/node-http-handler/src/node-http-handler.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import { request as hsRequest } from "https";
5252
describe("NodeHttpHandler", () => {
5353
describe("constructor and #handle", () => {
5454
const randomMaxSocket = Math.round(Math.random() * 50) + 1;
55+
const randomSocketAcquisitionWarningTimeout = Math.round(Math.random() * 10000) + 1;
5556

5657
beforeEach(() => {});
5758

@@ -93,6 +94,20 @@ describe("NodeHttpHandler", () => {
9394
expect(vi.mocked(hRequest as any).mock.calls[0][0]?.agent.maxSockets).toEqual(50);
9495
});
9596

97+
it.each([
98+
["an options hash", { socketAcquisitionWarningTimeout: randomSocketAcquisitionWarningTimeout }],
99+
[
100+
"a provider",
101+
async () => ({
102+
socketAcquisitionWarningTimeout: randomSocketAcquisitionWarningTimeout,
103+
}),
104+
],
105+
])("sets socketAcquisitionWarningTimeout correctly when input is %s", async (_, option) => {
106+
const nodeHttpHandler = new NodeHttpHandler(option);
107+
const config = await (nodeHttpHandler as any).configProvider;
108+
expect(config.socketAcquisitionWarningTimeout).toEqual(randomSocketAcquisitionWarningTimeout);
109+
});
110+
96111
it.each([
97112
["an options hash", { httpAgent: new http.Agent({ keepAlive: false, maxSockets: randomMaxSocket }) }],
98113
[

0 commit comments

Comments
 (0)