Skip to content

Commit

Permalink
chore(http): format test names (#4400)
Browse files Browse the repository at this point in the history
* initial commit

* remove brackets for classes
  • Loading branch information
timreichen authored Feb 27, 2024
1 parent 3736b01 commit 8fbd39d
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 93 deletions.
16 changes: 8 additions & 8 deletions http/cookie_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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), {});
Expand All @@ -35,7 +35,7 @@ Deno.test({
});

Deno.test({
name: "Cookie Name Validation",
name: "setCookie() validates names",
fn() {
const tokens = [
'"id"',
Expand Down Expand Up @@ -68,7 +68,7 @@ Deno.test({
});

Deno.test({
name: "Cookie Value Validation",
name: "setCookie() validates value",
fn() {
const tokens = [
"1f\tWa",
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -162,7 +162,7 @@ Deno.test({
});

Deno.test({
name: "Cookie Delete",
name: "deleteCookie()",
fn() {
let headers = new Headers();
deleteCookie(headers, "deno");
Expand All @@ -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" });
Expand Down Expand Up @@ -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), [{
Expand Down
14 changes: 7 additions & 7 deletions http/etag_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@ 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"`);
},
});

Deno.test({
name: "etag - calculate - string",
name: "calculate() handles string",
async fn() {
const actual = await calculate("hello deno");
assertEquals(actual, `"a-YdfmHmj2RiwOVqJupcf3PLK9PuJ"`);
},
});

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"`);
},
});

Deno.test({
name: "etag - calculate - Uint8Array",
name: "calculate() handles Uint8Array",
async fn() {
const actual = await calculate(encoder.encode("hello deno"));
assertEquals(actual, `"a-YdfmHmj2RiwOVqJupcf3PLK9PuJ"`);
},
});

Deno.test({
name: "etag - calculate - Deno.FileInfo",
name: "calculate() handles Deno.FileInfo",
async fn() {
const fixture: Deno.FileInfo = {
isFile: true,
Expand Down Expand Up @@ -69,7 +69,7 @@ Deno.test({
});

Deno.test({
name: "etag - ifMatch",
name: "ifMatch()",
async fn() {
assert(!ifMatch(`"abcdefg"`, await calculate("hello deno")));
assert(
Expand All @@ -95,7 +95,7 @@ Deno.test({
});

Deno.test({
name: "etag - ifNoneMatch",
name: "ifNoneMatch()",
async fn() {
assert(ifNoneMatch(`"abcdefg"`, await calculate("hello deno")));
assert(
Expand Down
30 changes: 15 additions & 15 deletions http/negotiation_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -23,7 +23,7 @@ Deno.test({
});

Deno.test({
name: "accepts - args",
name: "accepts() handles args",
fn() {
const req = new Request("https://example.com/", {
headers: {
Expand All @@ -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: {
Expand All @@ -48,23 +48,23 @@ 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");
},
});

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), ["*/*"]);
},
});

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" },
Expand All @@ -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" },
Expand All @@ -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" },
Expand All @@ -94,23 +94,23 @@ 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");
},
});

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), ["*"]);
},
});

Deno.test({
name: "acceptsLanguages - no args",
name: "acceptsLanguages() handles no args",
fn() {
const req = new Request("https://example.com/", {
headers: {
Expand All @@ -122,7 +122,7 @@ Deno.test({
});

Deno.test({
name: "acceptsLanguages - args",
name: "acceptsLanguages() handles args",
fn() {
const req = new Request("https://example.com/", {
headers: {
Expand All @@ -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" },
Expand All @@ -144,15 +144,15 @@ 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");
},
});

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), ["*"]);
Expand Down
4 changes: 2 additions & 2 deletions http/server_sent_event_stream_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(),
Expand Down
Loading

0 comments on commit 8fbd39d

Please sign in to comment.