forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ext/node): polyfill response._implicitHeader method (denoland#18738)
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. | ||
|
||
import http from "node:http"; | ||
import { assertEquals } from "../../../test_util/std/testing/asserts.ts"; | ||
import { assertSpyCalls, spy } from "../../../test_util/std/testing/mock.ts"; | ||
import { deferred } from "../../../test_util/std/async/deferred.ts"; | ||
|
||
Deno.test("[node/http] ServerResponse _implicitHeader", async () => { | ||
const d = deferred<void>(); | ||
const server = http.createServer((_req, res) => { | ||
const writeHeadSpy = spy(res, "writeHead"); | ||
// deno-lint-ignore no-explicit-any | ||
(res as any)._implicitHeader(); | ||
assertSpyCalls(writeHeadSpy, 1); | ||
writeHeadSpy.restore(); | ||
res.end("Hello World"); | ||
}); | ||
|
||
server.listen(async () => { | ||
const { port } = server.address() as { port: number }; | ||
const res = await fetch(`https://localhost:${port}`); | ||
assertEquals(await res.text(), "Hello World"); | ||
server.close(() => { | ||
d.resolve(); | ||
}); | ||
}); | ||
|
||
await d; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters