From 4000a4c18c1c6371f49a6ea6ed700cdd3ee48479 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 26 Feb 2024 14:58:04 +0100 Subject: [PATCH 1/2] initial commit --- http/cookie_test.ts | 16 +++--- http/etag_test.ts | 14 +++--- http/negotiation_test.ts | 30 +++++------ http/server_test.ts | 105 +++++++++++++++++++-------------------- http/status_test.ts | 16 +++--- 5 files changed, 90 insertions(+), 91 deletions(-) diff --git a/http/cookie_test.ts b/http/cookie_test.ts index 743d880662f4..b55b21d58e12 100644 --- a/http/cookie_test.ts +++ b/http/cookie_test.ts @@ -8,7 +8,7 @@ import { import { assert, assertEquals, assertThrows } from "../assert/mod.ts"; Deno.test({ - name: "Cookie parser", + name: "getCookies() parses cookie", fn() { let headers = new Headers(); assertEquals(getCookies(headers), {}); @@ -35,7 +35,7 @@ Deno.test({ }); Deno.test({ - name: "Cookie Name Validation", + name: "setCookie() validates names", fn() { const tokens = [ '"id"', @@ -68,7 +68,7 @@ Deno.test({ }); Deno.test({ - name: "Cookie Value Validation", + name: "setCookie() validates value", fn() { const tokens = [ "1f\tWa", @@ -116,7 +116,7 @@ Deno.test({ }); Deno.test({ - name: "Cookie Path Validation", + name: "setCookie() validates path", fn() { const path = "/;domain=sub.domain.com"; const headers = new Headers(); @@ -138,7 +138,7 @@ Deno.test({ }); Deno.test({ - name: "Cookie Domain Validation", + name: "setCookie() validates domain", fn() { const tokens = ["-domain.com", "domain.org.", "domain.org-"]; const headers = new Headers(); @@ -162,7 +162,7 @@ Deno.test({ }); Deno.test({ - name: "Cookie Delete", + name: "deleteCookie()", fn() { let headers = new Headers(); deleteCookie(headers, "deno"); @@ -186,7 +186,7 @@ Deno.test({ }); Deno.test({ - name: "Cookie Set", + name: "setCookie() handles Set-Cookie", fn() { let headers = new Headers(); setCookie(headers, { name: "Space", value: "Cat" }); @@ -385,7 +385,7 @@ Deno.test({ }); Deno.test({ - name: "Set-Cookie parser", + name: "setCookie() parses Set-Cookie", fn() { let headers = new Headers({ "set-cookie": "Space=Cat" }); assertEquals(getSetCookies(headers), [{ diff --git a/http/etag_test.ts b/http/etag_test.ts index ee061166e44b..3095e3fb1631 100644 --- a/http/etag_test.ts +++ b/http/etag_test.ts @@ -7,7 +7,7 @@ import { calculate, ifMatch, ifNoneMatch } from "./etag.ts"; const encoder = new TextEncoder(); Deno.test({ - name: "etag - calculate - string - empty", + name: "calculate() handles empty string", async fn() { const actual = await calculate(""); assertEquals(actual, `"0-47DEQpj8HBSa+/TImW+5JCeuQeR"`); @@ -15,7 +15,7 @@ Deno.test({ }); Deno.test({ - name: "etag - calculate - string", + name: "calculate() handles string", async fn() { const actual = await calculate("hello deno"); assertEquals(actual, `"a-YdfmHmj2RiwOVqJupcf3PLK9PuJ"`); @@ -23,7 +23,7 @@ Deno.test({ }); Deno.test({ - name: "etag - calculate - Uint8Array - empty", + name: "calculate() handles empty Uint8Array", async fn() { const actual = await calculate(new Uint8Array()); assertEquals(actual, `"0-47DEQpj8HBSa+/TImW+5JCeuQeR"`); @@ -31,7 +31,7 @@ Deno.test({ }); Deno.test({ - name: "etag - calculate - Uint8Array", + name: "calculate() handles Uint8Array", async fn() { const actual = await calculate(encoder.encode("hello deno")); assertEquals(actual, `"a-YdfmHmj2RiwOVqJupcf3PLK9PuJ"`); @@ -39,7 +39,7 @@ Deno.test({ }); Deno.test({ - name: "etag - calculate - Deno.FileInfo", + name: "calculate() handles Deno.FileInfo", async fn() { const fixture: Deno.FileInfo = { isFile: true, @@ -69,7 +69,7 @@ Deno.test({ }); Deno.test({ - name: "etag - ifMatch", + name: "ifMatch()", async fn() { assert(!ifMatch(`"abcdefg"`, await calculate("hello deno"))); assert( @@ -95,7 +95,7 @@ Deno.test({ }); Deno.test({ - name: "etag - ifNoneMatch", + name: "ifNoneMatch()", async fn() { assert(ifNoneMatch(`"abcdefg"`, await calculate("hello deno"))); assert( diff --git a/http/negotiation_test.ts b/http/negotiation_test.ts index 2bbad148c4b9..66094fe669f6 100644 --- a/http/negotiation_test.ts +++ b/http/negotiation_test.ts @@ -4,7 +4,7 @@ import { assertEquals } from "../assert/mod.ts"; import { accepts, acceptsEncodings, acceptsLanguages } from "./negotiation.ts"; Deno.test({ - name: "accepts - no args", + name: "accepts() handles no args", fn() { const req = new Request("https://example.com/", { headers: { @@ -23,7 +23,7 @@ Deno.test({ }); Deno.test({ - name: "accepts - args", + name: "accepts() handles args", fn() { const req = new Request("https://example.com/", { headers: { @@ -36,7 +36,7 @@ Deno.test({ }); Deno.test({ - name: "accepts - no match", + name: "accepts() handles no match", fn() { const req = new Request("https://example.com/", { headers: { @@ -48,7 +48,7 @@ Deno.test({ }); Deno.test({ - name: "accepts - args + no header", + name: "accepts() handles args and no header", fn() { const req = new Request("https://example.com/"); assertEquals(accepts(req, "text/html", "image/webp"), "text/html"); @@ -56,7 +56,7 @@ Deno.test({ }); Deno.test({ - name: "accepts - no args + no header", + name: "accepts() handles no args and no header", fn() { const req = new Request("https://example.com/"); assertEquals(accepts(req), ["*/*"]); @@ -64,7 +64,7 @@ Deno.test({ }); Deno.test({ - name: "acceptsEncodings - no args", + name: "acceptsEncodings() handles no args", fn() { const req = new Request("https://example.com/", { headers: { "accept-encoding": "deflate, gzip;q=1.0, *;q=0.5" }, @@ -74,7 +74,7 @@ Deno.test({ }); Deno.test({ - name: "acceptsEncodings - args", + name: "acceptsEncodings() handles args", fn() { const req = new Request("https://example.com/", { headers: { "accept-encoding": "deflate, gzip;q=1.0, *;q=0.5" }, @@ -84,7 +84,7 @@ Deno.test({ }); Deno.test({ - name: "acceptsEncodings - no match", + name: "acceptsEncodings() handles no match", fn() { const req = new Request("https://example.com/", { headers: { "accept-encoding": "deflate, gzip" }, @@ -94,7 +94,7 @@ Deno.test({ }); Deno.test({ - name: "acceptsEncodings - args + no header", + name: "acceptsEncodings() handles args and no header", fn() { const req = new Request("https://example.com/"); assertEquals(acceptsEncodings(req, "gzip", "identity"), "gzip"); @@ -102,7 +102,7 @@ Deno.test({ }); Deno.test({ - name: "acceptsEncodings - no args + no header", + name: "acceptsEncodings() handles no args and no header", fn() { const req = new Request("https://example.com/"); assertEquals(acceptsEncodings(req), ["*"]); @@ -110,7 +110,7 @@ Deno.test({ }); Deno.test({ - name: "acceptsLanguages - no args", + name: "acceptsLanguages() handles no args", fn() { const req = new Request("https://example.com/", { headers: { @@ -122,7 +122,7 @@ Deno.test({ }); Deno.test({ - name: "acceptsLanguages - args", + name: "acceptsLanguages() handles args", fn() { const req = new Request("https://example.com/", { headers: { @@ -134,7 +134,7 @@ Deno.test({ }); Deno.test({ - name: "acceptsLanguages - no match", + name: "acceptsLanguages() handles no match", fn() { const req = new Request("https://example.com/", { headers: { "accept-language": "fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7" }, @@ -144,7 +144,7 @@ Deno.test({ }); Deno.test({ - name: "acceptsLanguages - args + no header", + name: "acceptsLanguages() handles args and no header", fn() { const req = new Request("https://example.com/"); assertEquals(acceptsLanguages(req, "en-gb", "en-us", "en"), "en-gb"); @@ -152,7 +152,7 @@ Deno.test({ }); Deno.test({ - name: "acceptsLanguages - no args + no header", + name: "acceptsLanguages() handles no args and no header", fn() { const req = new Request("https://example.com/"); assertEquals(acceptsLanguages(req), ["*"]); diff --git a/http/server_test.ts b/http/server_test.ts index 5b6013e05568..abd29637e378 100644 --- a/http/server_test.ts +++ b/http/server_test.ts @@ -127,7 +127,7 @@ class MockListener implements Deno.Listener { } Deno.test( - "Server.addrs should expose the addresses the server is listening on", + "Server() exposes the addresses the server is listening on as addrs property", async () => { const listenerOneOptions = { hostname: "127.0.0.1", @@ -185,7 +185,7 @@ Deno.test( }, ); -Deno.test("Server.closed should expose whether it is closed", () => { +Deno.test("Server() exposes whether the server is closed as closed property", () => { const handler = () => new Response(); const server = new Server({ handler }); try { @@ -197,7 +197,7 @@ Deno.test("Server.closed should expose whether it is closed", () => { }); Deno.test( - "Server.close should throw an error if the server is already closed", + "Server.close() throws an error if the server is already closed", () => { const handler = () => new Response(); const server = new Server({ handler }); @@ -208,7 +208,7 @@ Deno.test( ); Deno.test( - "Server.serve should throw an error if the server is already closed", + "Server.serve() throws an error if the server is already closed", async () => { const handler = () => new Response(); const server = new Server({ handler }); @@ -229,7 +229,7 @@ Deno.test( ); Deno.test( - "Server.listenAndServe should throw an error if the server is already closed", + "Server.listenAndServe() throws an error if the server is already closed", async () => { const handler = () => new Response(); const server = new Server({ handler }); @@ -244,7 +244,7 @@ Deno.test( ); Deno.test( - "Server.listenAndServeTls should throw an error if the server is already closed", + "Server.listenAndServeTls() throws an error if the server is already closed", async () => { const handler = () => new Response(); const server = new Server({ handler }); @@ -262,7 +262,7 @@ Deno.test( ); Deno.test( - "serveListener should not overwrite an abort signal handler", + "serveListener() does not overwrite an abort signal handler", async () => { const listenOptions = { hostname: "localhost", @@ -289,7 +289,7 @@ Deno.test( ); Deno.test( - "serve should not overwrite an abort signal handler", + "serve() does not overwrite an abort signal handler", async () => { const handler = () => new Response(); const onAbort = () => {}; @@ -313,7 +313,7 @@ Deno.test( ); Deno.test( - "serveTls should not overwrite an abort signal handler", + "serveTls() not overwrite an abort signal handler", async () => { const certFile = join(testdataDir, "tls/localhost.crt"); const keyFile = join(testdataDir, "tls/localhost.key"); @@ -341,7 +341,7 @@ Deno.test( ); Deno.test( - "serveListener should not throw if abort when the server is already closed", + "serveListener() does not throw if abort when the server is already closed", async () => { const listenOptions = { hostname: "localhost", @@ -366,7 +366,7 @@ Deno.test( ); Deno.test( - "serve should not throw if abort when the server is already closed", + "serve() does not throw if abort when the server is already closed", async () => { const handler = () => new Response(); const abortController = new AbortController(); @@ -388,7 +388,7 @@ Deno.test( ); Deno.test( - "serveTls should not throw if abort when the server is already closed", + "serveTls() does not throw if abort when the server is already closed", async () => { const certFile = join(testdataDir, "tls/localhost.crt"); const keyFile = join(testdataDir, "tls/localhost.key"); @@ -413,7 +413,7 @@ Deno.test( }, ); -Deno.test(`Server.serve should response with internal server error if response body is already consumed`, async () => { +Deno.test(`Server.serve() responds with internal server error if response body is already consumed`, async () => { const listenOptions = { hostname: "localhost", port: getPort(), @@ -443,7 +443,7 @@ Deno.test(`Server.serve should response with internal server error if response b } }); -Deno.test(`Server.serve should handle requests`, async () => { +Deno.test(`Server.serve() handles requests`, async () => { const listenOptions = { hostname: "localhost", port: getPort(), @@ -470,7 +470,7 @@ Deno.test(`Server.serve should handle requests`, async () => { } }); -Deno.test(`Server.listenAndServe should handle requests`, async () => { +Deno.test(`Server.listenAndServe() handles requests`, async () => { const hostname = "localhost"; const port = getPort(); const url = `http://${hostname}:${port}`; @@ -497,7 +497,7 @@ Deno.test({ // PermissionDenied: Permission denied (os error 13) // Will pass if run as root user. ignore: true, - name: `Server.listenAndServe should handle requests on the default HTTP port`, + name: `Server.listenAndServe() handles requests on the default HTTP port`, fn: async () => { const addr = "localhost"; const url = `http://${addr}`; @@ -521,7 +521,7 @@ Deno.test({ }, }); -Deno.test(`Server.listenAndServeTls should handle requests`, async () => { +Deno.test(`Server.listenAndServeTls() handles requests`, async () => { const hostname = "localhost"; const port = getPort(); const addr = `${hostname}:${port}`; @@ -579,8 +579,7 @@ Deno.test({ // PermissionDenied: Permission denied (os error 13) // Will pass if run as root user. ignore: true, - name: - `Server.listenAndServeTls should handle requests on the default HTTPS port`, + name: `Server.listenAndServeTls() handles requests on the default HTTPS port`, fn: async () => { const hostname = "localhost"; const port = 443; @@ -639,7 +638,7 @@ Deno.test({ }, }); -Deno.test(`serve should handle requests`, async () => { +Deno.test(`serve() handles requests`, async () => { const listenOptions = { hostname: "localhost", port: getPort(), @@ -668,7 +667,7 @@ Deno.test(`serve should handle requests`, async () => { } }); -Deno.test(`serve should handle requests`, async () => { +Deno.test(`serve() handles requests`, async () => { const hostname = "localhost"; const port = getPort(); const url = `http://${hostname}:${port}`; @@ -695,7 +694,7 @@ Deno.test(`serve should handle requests`, async () => { } }); -Deno.test(`serve listens on the port 8000 by default`, async () => { +Deno.test(`serve() listens on the port 8000 by default`, async () => { const url = "http://localhost:8000"; const body = "Hello from port 8000"; @@ -716,7 +715,7 @@ Deno.test(`serve listens on the port 8000 by default`, async () => { } }); -Deno.test(`serve should handle websocket requests`, async () => { +Deno.test(`serve() handles websocket requests`, async () => { const hostname = "localhost"; const port = getPort(); const url = `ws://${hostname}:${port}`; @@ -756,7 +755,7 @@ Deno.test(`serve should handle websocket requests`, async () => { } }); -Deno.test(`Server.listenAndServeTls should handle requests`, async () => { +Deno.test(`Server.listenAndServeTls() handles requests`, async () => { const hostname = "localhost"; const port = getPort(); const addr = `${hostname}:${port}`; @@ -817,7 +816,7 @@ Deno.test(`Server.listenAndServeTls should handle requests`, async () => { }); Deno.test( - "Server should not reject when the listener is closed (though the server will continually try and fail to accept connections on the listener until it is closed)", + "Server() does not reject when the listener is closed (though the server will continually try and fail to accept connections on the listener until it is closed)", async () => { using listener = Deno.listen({ port: getPort() }); const handler = () => new Response(); @@ -836,7 +835,7 @@ Deno.test( ); Deno.test( - "Server should not reject when there is a tls handshake with tcp corruption", + "Server() does not reject when there is a tls handshake with tcp corruption", async () => { const conn = createMockConn(); const rejectionError = new Deno.errors.InvalidData( @@ -859,7 +858,7 @@ Deno.test( ); Deno.test( - "Server should not reject when the tls session is aborted", + "Server() does not reject when the tls session is aborted", async () => { const conn = createMockConn(); const rejectionError = new Deno.errors.ConnectionReset( @@ -881,7 +880,7 @@ Deno.test( }, ); -Deno.test("Server should not reject when the socket is closed", async () => { +Deno.test("Server() does not reject when the socket is closed", async () => { const conn = createMockConn(); const rejectionError = new Deno.errors.NotConnected( "test-socket-closed-error", @@ -902,7 +901,7 @@ Deno.test("Server should not reject when the socket is closed", async () => { }); Deno.test( - "Server should implement a backoff delay when accepting a connection throws an expected error and reset the backoff when successfully accepting a connection again", + "Server() does implement a backoff delay when accepting a connection throws an expected error and reset the backoff when successfully accepting a connection again", async () => { // acceptDelay(n) = 5 * 2^n for n=0...7 capped at 1000 afterwards. const expectedBackoffDelays = [ @@ -984,7 +983,7 @@ Deno.test( }, ); -Deno.test("Server should not leak async ops when closed", () => { +Deno.test("Server() does not leak async ops when closed", () => { const hostname = "127.0.0.1"; const port = getPort(); const handler = () => new Response(); @@ -994,7 +993,7 @@ Deno.test("Server should not leak async ops when closed", () => { // Otherwise, the test would fail with: AssertionError: Test case is leaking async ops. }); -Deno.test("Server should abort accept backoff delay when closing", async () => { +Deno.test("Server() aborts accept backoff delay when closing", async () => { const hostname = "127.0.0.1"; const port = getPort(); const handler = () => new Response(); @@ -1022,7 +1021,7 @@ Deno.test("Server should abort accept backoff delay when closing", async () => { server.close(); }); -Deno.test("Server should reject if the listener throws an unexpected error accepting a connection", async () => { +Deno.test("Server() rejects if the listener throws an unexpected error accepting a connection", async () => { const conn = createMockConn(); const rejectionError = new Error("test-unexpected-error"); const listener = new MockListener({ conn, rejectionError }); @@ -1036,7 +1035,7 @@ Deno.test("Server should reject if the listener throws an unexpected error accep }); Deno.test( - "Server should reject if the listener throws an unexpected error accepting a connection", + "Server() rejects if the listener throws an unexpected error accepting a connection", async () => { const conn = createMockConn(); const rejectionError = new Error("test-unexpected-error"); @@ -1052,7 +1051,7 @@ Deno.test( ); Deno.test( - "Server should not reject when the connection is closed before the message is complete", + "Server() does not reject when the connection is closed before the message is complete", async () => { const listenOptions = { hostname: "localhost", @@ -1091,7 +1090,7 @@ Deno.test( }, ); -Deno.test("Server should not reject when the handler throws", async () => { +Deno.test("Server() does not reject when the handler throws", async () => { const listenOptions = { hostname: "localhost", port: getPort(), @@ -1120,7 +1119,7 @@ Deno.test("Server should not reject when the handler throws", async () => { await servePromise; }); -Deno.test("Server should not close the http2 downstream connection when the response stream throws", async () => { +Deno.test("Server() does not close the http2 downstream connection when the response stream throws", async () => { const listenOptions = { hostname: "localhost", port: getPort(), @@ -1186,7 +1185,7 @@ Deno.test("Server should not close the http2 downstream connection when the resp await servePromise; }); -Deno.test("Server should be able to parse IPV6 addresses", async () => { +Deno.test("Server() parses IPV6 addresses", async () => { const hostname = "[::1]"; const port = getPort(); const url = `http://${hostname}:${port}`; @@ -1213,7 +1212,7 @@ Deno.test("Server should be able to parse IPV6 addresses", async () => { } }); -Deno.test("Server.serve can be called multiple times", async () => { +Deno.test("Server.serve() can be called multiple times", async () => { const listenerOneOptions = { hostname: "localhost", port: getPort(), @@ -1259,7 +1258,7 @@ Deno.test("Server.serve can be called multiple times", async () => { }); Deno.test( - "Server.listenAndServe should throw if called multiple times", + "Server.listenAndServe() throws if called multiple times", async () => { const handler = () => unreachable(); @@ -1276,7 +1275,7 @@ Deno.test( ); Deno.test( - "Server.listenAndServeTls should throw if called multiple times", + "Server.listenAndServeTls() throws if called multiple times", async () => { const handler = () => unreachable(); @@ -1299,7 +1298,7 @@ Deno.test( ); Deno.test( - "Handler is called with the request instance and connection information", + "Sever() handler is called with the request instance and connection information", async () => { const hostname = "127.0.0.1"; const port = getPort(); @@ -1343,7 +1342,7 @@ Deno.test( }, ); -Deno.test("Default onError is called when Handler throws", async () => { +Deno.test("serve() calls onError when Handler throws", async () => { const hostname = "localhost"; const port = getPort(); const url = `http://${hostname}:${port}`; @@ -1368,7 +1367,7 @@ Deno.test("Default onError is called when Handler throws", async () => { } }); -Deno.test("Custom onError is called when Handler throws", async () => { +Deno.test("serve() calls custom onError when Handler throws", async () => { const hostname = "localhost"; const port = getPort(); const url = `http://${hostname}:${port}`; @@ -1397,7 +1396,7 @@ Deno.test("Custom onError is called when Handler throws", async () => { } }); -Deno.test("Custom onError is called when Handler throws", async () => { +Deno.test("serveListener() calls custom onError when Handler throws", async () => { const listenOptions = { hostname: "localhost", port: getPort(), @@ -1428,7 +1427,7 @@ Deno.test("Custom onError is called when Handler throws", async () => { } }); -Deno.test("Server.listenAndServeTls should support custom onError", async () => { +Deno.test("Server.serveTls() supports custom onError", async () => { const hostname = "localhost"; const port = getPort(); const certFile = join(testdataDir, "tls/localhost.crt"); @@ -1482,7 +1481,7 @@ Deno.test("Server.listenAndServeTls should support custom onError", async () => } }); -Deno.test("serve - onListen callback is called when the server started listening", () => { +Deno.test("serve() calls onListen callback when the server started listening", () => { const abortController = new AbortController(); return serve((_) => new Response("hello"), { async onListen({ hostname, port }) { @@ -1496,7 +1495,7 @@ Deno.test("serve - onListen callback is called when the server started listening }); }); -Deno.test("serve - onListen callback is called with ephemeral port", () => { +Deno.test("serve() calls onListen callback with ephemeral port", () => { const abortController = new AbortController(); return serve((_) => new Response("hello"), { port: 0, @@ -1512,7 +1511,7 @@ Deno.test("serve - onListen callback is called with ephemeral port", () => { }); }); -Deno.test("serve - doesn't print the message when onListen set to undefined", async () => { +Deno.test("serve() doesn't print the message when onListen set to undefined", async () => { const command = new Deno.Command(Deno.execPath(), { args: [ "eval", @@ -1529,7 +1528,7 @@ Deno.test("serve - doesn't print the message when onListen set to undefined", as assertEquals(new TextDecoder().decode(stdout), ""); }); -Deno.test("serve - can print customized start-up message in onListen handler", async () => { +Deno.test("serve() can print customized start-up message in onListen handler", async () => { const command = new Deno.Command(Deno.execPath(), { args: [ "eval", @@ -1551,7 +1550,7 @@ Deno.test("serve - can print customized start-up message in onListen handler", a ); }); -Deno.test("serveTls - onListen callback is called with ephemeral port", () => { +Deno.test("serveTls() calls onListen callback with ephemeral port", () => { const abortController = new AbortController(); return serveTls((_) => new Response("hello"), { port: 0, @@ -1575,7 +1574,7 @@ Deno.test("serveTls - onListen callback is called with ephemeral port", () => { }); }); -Deno.test("serveTls - cert, key can be injected directly from memory rather than file system.", () => { +Deno.test("serveTls() handles cert key injection directly from memory rather than file system.", () => { const abortController = new AbortController(); return serveTls((_) => new Response("hello"), { port: 0, @@ -1599,7 +1598,7 @@ Deno.test("serveTls - cert, key can be injected directly from memory rather than }); }); -Deno.test("serve - doesn't throw with string port number", () => { +Deno.test("serve() doesn't throw with string port number", () => { const ac = new AbortController(); return serve((_) => new Response("hello"), { // deno-lint-ignore no-explicit-any @@ -1611,7 +1610,7 @@ Deno.test("serve - doesn't throw with string port number", () => { }); }); -Deno.test("serveTls - doesn't throw with string port number", () => { +Deno.test("serveTls() doesn't throw with string port number", () => { const ac = new AbortController(); return serveTls((_) => new Response("hello"), { // deno-lint-ignore no-explicit-any diff --git a/http/status_test.ts b/http/status_test.ts index 877921f4f5d2..f580db2d5679 100644 --- a/http/status_test.ts +++ b/http/status_test.ts @@ -13,7 +13,7 @@ import { import { assert, assertEquals } from "../assert/mod.ts"; Deno.test({ - name: "http/http_status - Status", + name: "STATUS_CODE", fn() { // just spot check a few common codes assertEquals(STATUS_CODE.OK, 200); @@ -24,7 +24,7 @@ Deno.test({ }); Deno.test({ - name: "http/http_status - STATUS_TEXT", + name: "STATUS_TEXT", fn() { // just spot check a few common codes assertEquals(STATUS_TEXT[STATUS_CODE.OK], "OK"); @@ -38,7 +38,7 @@ Deno.test({ }); Deno.test({ - name: "http/http_status - isInformationalStatus()", + name: "isInformationalStatus()", fn() { assert(isInformationalStatus(STATUS_CODE.Continue)); assert(!isInformationalStatus(STATUS_CODE.OK)); @@ -48,7 +48,7 @@ Deno.test({ }); Deno.test({ - name: "http/http_status - isSuccessfulStatus()", + name: "isSuccessfulStatus()", fn() { assert(isSuccessfulStatus(STATUS_CODE.OK)); assert(!isSuccessfulStatus(STATUS_CODE.NotFound)); @@ -58,7 +58,7 @@ Deno.test({ }); Deno.test({ - name: "http/http_status - isRedirectStatus()", + name: "isRedirectStatus()", fn() { assert(isRedirectStatus(STATUS_CODE.Found)); assert(!isRedirectStatus(STATUS_CODE.NotFound)); @@ -68,7 +68,7 @@ Deno.test({ }); Deno.test({ - name: "http/http_status - isClientErrorStatus()", + name: "isClientErrorStatus()", fn() { assert(isClientErrorStatus(STATUS_CODE.NotFound)); assert(!isClientErrorStatus(STATUS_CODE.InternalServerError)); @@ -78,7 +78,7 @@ Deno.test({ }); Deno.test({ - name: "http/http_status - isServerErrorStatus()", + name: "isServerErrorStatus()", fn() { assert(isServerErrorStatus(STATUS_CODE.InternalServerError)); assert(!isServerErrorStatus(STATUS_CODE.NotFound)); @@ -88,7 +88,7 @@ Deno.test({ }); Deno.test({ - name: "http/http_status - isErrorStatus()", + name: "isErrorStatus()", fn() { assert(isErrorStatus(STATUS_CODE.InternalServerError)); assert(isErrorStatus(STATUS_CODE.NotFound)); From 25dca31722efbaf5d41f0318c3299829d4b7065a Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 27 Feb 2024 10:19:51 +0100 Subject: [PATCH 2/2] remove brackets for classes --- http/server_sent_event_stream_test.ts | 4 ++-- http/server_test.ts | 30 +++++++++++++-------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/http/server_sent_event_stream_test.ts b/http/server_sent_event_stream_test.ts index 1cc68d6d8668..c41f9146877d 100644 --- a/http/server_sent_event_stream_test.ts +++ b/http/server_sent_event_stream_test.ts @@ -14,7 +14,7 @@ function createStream( .pipeThrough(new TextDecoderStream()); } -Deno.test("ServerSentEventStream() enqueues a stringified server-sent event message object", async () => { +Deno.test("ServerSentEventStream enqueues a stringified server-sent event message object", async () => { const stream = createStream([ { comment: "a", @@ -58,7 +58,7 @@ Deno.test("ServerSentEventStream() enqueues a stringified server-sent event mess ); }); -Deno.test("ServerSentEventStream() throws if single-line fields contain a newline", async () => { +Deno.test("ServerSentEventStream throws if single-line fields contain a newline", async () => { // Comment await assertRejects( async () => await createStream([{ comment: "a\n" }]).getReader().read(), diff --git a/http/server_test.ts b/http/server_test.ts index abd29637e378..52af40444502 100644 --- a/http/server_test.ts +++ b/http/server_test.ts @@ -127,7 +127,7 @@ class MockListener implements Deno.Listener { } Deno.test( - "Server() exposes the addresses the server is listening on as addrs property", + "Server exposes the addresses the server is listening on as addrs property", async () => { const listenerOneOptions = { hostname: "127.0.0.1", @@ -185,7 +185,7 @@ Deno.test( }, ); -Deno.test("Server() exposes whether the server is closed as closed property", () => { +Deno.test("Server exposes whether the server is closed as closed property", () => { const handler = () => new Response(); const server = new Server({ handler }); try { @@ -816,7 +816,7 @@ Deno.test(`Server.listenAndServeTls() handles requests`, async () => { }); Deno.test( - "Server() does not reject when the listener is closed (though the server will continually try and fail to accept connections on the listener until it is closed)", + "Server does not reject when the listener is closed (though the server will continually try and fail to accept connections on the listener until it is closed)", async () => { using listener = Deno.listen({ port: getPort() }); const handler = () => new Response(); @@ -835,7 +835,7 @@ Deno.test( ); Deno.test( - "Server() does not reject when there is a tls handshake with tcp corruption", + "Server does not reject when there is a tls handshake with tcp corruption", async () => { const conn = createMockConn(); const rejectionError = new Deno.errors.InvalidData( @@ -858,7 +858,7 @@ Deno.test( ); Deno.test( - "Server() does not reject when the tls session is aborted", + "Server does not reject when the tls session is aborted", async () => { const conn = createMockConn(); const rejectionError = new Deno.errors.ConnectionReset( @@ -880,7 +880,7 @@ Deno.test( }, ); -Deno.test("Server() does not reject when the socket is closed", async () => { +Deno.test("Server does not reject when the socket is closed", async () => { const conn = createMockConn(); const rejectionError = new Deno.errors.NotConnected( "test-socket-closed-error", @@ -901,7 +901,7 @@ Deno.test("Server() does not reject when the socket is closed", async () => { }); Deno.test( - "Server() does implement a backoff delay when accepting a connection throws an expected error and reset the backoff when successfully accepting a connection again", + "Server does implement a backoff delay when accepting a connection throws an expected error and reset the backoff when successfully accepting a connection again", async () => { // acceptDelay(n) = 5 * 2^n for n=0...7 capped at 1000 afterwards. const expectedBackoffDelays = [ @@ -983,7 +983,7 @@ Deno.test( }, ); -Deno.test("Server() does not leak async ops when closed", () => { +Deno.test("Server does not leak async ops when closed", () => { const hostname = "127.0.0.1"; const port = getPort(); const handler = () => new Response(); @@ -993,7 +993,7 @@ Deno.test("Server() does not leak async ops when closed", () => { // Otherwise, the test would fail with: AssertionError: Test case is leaking async ops. }); -Deno.test("Server() aborts accept backoff delay when closing", async () => { +Deno.test("Server aborts accept backoff delay when closing", async () => { const hostname = "127.0.0.1"; const port = getPort(); const handler = () => new Response(); @@ -1021,7 +1021,7 @@ Deno.test("Server() aborts accept backoff delay when closing", async () => { server.close(); }); -Deno.test("Server() rejects if the listener throws an unexpected error accepting a connection", async () => { +Deno.test("Server rejects if the listener throws an unexpected error accepting a connection", async () => { const conn = createMockConn(); const rejectionError = new Error("test-unexpected-error"); const listener = new MockListener({ conn, rejectionError }); @@ -1035,7 +1035,7 @@ Deno.test("Server() rejects if the listener throws an unexpected error accepting }); Deno.test( - "Server() rejects if the listener throws an unexpected error accepting a connection", + "Server rejects if the listener throws an unexpected error accepting a connection", async () => { const conn = createMockConn(); const rejectionError = new Error("test-unexpected-error"); @@ -1051,7 +1051,7 @@ Deno.test( ); Deno.test( - "Server() does not reject when the connection is closed before the message is complete", + "Server does not reject when the connection is closed before the message is complete", async () => { const listenOptions = { hostname: "localhost", @@ -1090,7 +1090,7 @@ Deno.test( }, ); -Deno.test("Server() does not reject when the handler throws", async () => { +Deno.test("Server does not reject when the handler throws", async () => { const listenOptions = { hostname: "localhost", port: getPort(), @@ -1119,7 +1119,7 @@ Deno.test("Server() does not reject when the handler throws", async () => { await servePromise; }); -Deno.test("Server() does not close the http2 downstream connection when the response stream throws", async () => { +Deno.test("Server does not close the http2 downstream connection when the response stream throws", async () => { const listenOptions = { hostname: "localhost", port: getPort(), @@ -1185,7 +1185,7 @@ Deno.test("Server() does not close the http2 downstream connection when the resp await servePromise; }); -Deno.test("Server() parses IPV6 addresses", async () => { +Deno.test("Server parses IPV6 addresses", async () => { const hostname = "[::1]"; const port = getPort(); const url = `http://${hostname}:${port}`;