diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2023-04-18 15:20:36 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-18 15:20:36 +0900 |
commit | 6efaef606af890e05deab0a892b1214f7f8421a9 (patch) | |
tree | 911cc74ea1b67a5b45711b6c0633850eac8e47e6 /cli/tests/unit_node/http_test.ts | |
parent | d2d62b6312f9c09f91e26acd0b4d88b3ddcf94cf (diff) |
fix(ext/node): polyfill response._implicitHeader method (#18738)
Diffstat (limited to 'cli/tests/unit_node/http_test.ts')
-rw-r--r-- | cli/tests/unit_node/http_test.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/cli/tests/unit_node/http_test.ts b/cli/tests/unit_node/http_test.ts new file mode 100644 index 000000000..c32bf62f2 --- /dev/null +++ b/cli/tests/unit_node/http_test.ts @@ -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(`http://localhost:${port}`); + assertEquals(await res.text(), "Hello World"); + server.close(() => { + d.resolve(); + }); + }); + + await d; +}); |