chore: bump std to 208 and deal with deprecations (#2081)
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
This commit is contained in:
co-authored by
Marvin Hagemeister
parent
6a90fdbf1b
commit
b902205feb
+8
-8
@@ -13,13 +13,13 @@ export {
|
||||
assertNotMatch,
|
||||
assertRejects,
|
||||
assertStringIncludes,
|
||||
} from "https://deno.land/std@0.205.0/assert/mod.ts";
|
||||
export { assertSnapshot } from "https://deno.land/std@0.205.0/testing/snapshot.ts";
|
||||
} from "https://deno.land/std@0.208.0/assert/mod.ts";
|
||||
export { assertSnapshot } from "https://deno.land/std@0.208.0/testing/snapshot.ts";
|
||||
export {
|
||||
TextLineStream,
|
||||
} from "https://deno.land/std@0.205.0/streams/text_line_stream.ts";
|
||||
export { delay } from "https://deno.land/std@0.205.0/async/delay.ts";
|
||||
export { retry } from "https://deno.land/std@0.205.0/async/retry.ts";
|
||||
} from "https://deno.land/std@0.208.0/streams/text_line_stream.ts";
|
||||
export { delay } from "https://deno.land/std@0.208.0/async/delay.ts";
|
||||
export { retry } from "https://deno.land/std@0.208.0/async/retry.ts";
|
||||
export {
|
||||
default as puppeteer,
|
||||
Page,
|
||||
@@ -32,7 +32,7 @@ export {
|
||||
} from "https://esm.sh/linkedom@0.15.1";
|
||||
export { defineConfig, type Preset } from "https://esm.sh/@twind/core@1.1.3";
|
||||
export { default as presetTailwind } from "https://esm.sh/@twind/preset-tailwind@1.1.4";
|
||||
export { copy } from "https://deno.land/std@0.205.0/fs/mod.ts";
|
||||
export { copy } from "https://deno.land/std@0.208.0/fs/mod.ts";
|
||||
export {
|
||||
basename,
|
||||
dirname,
|
||||
@@ -40,5 +40,5 @@ export {
|
||||
fromFileUrl,
|
||||
join,
|
||||
relative,
|
||||
} from "https://deno.land/std@0.205.0/path/mod.ts";
|
||||
export * as JSONC from "https://deno.land/std@0.205.0/jsonc/mod.ts";
|
||||
} from "https://deno.land/std@0.208.0/path/mod.ts";
|
||||
export * as JSONC from "https://deno.land/std@0.208.0/jsonc/mod.ts";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { assert, assertEquals, assertStringIncludes } from "./deps.ts";
|
||||
import { Status } from "../server.ts";
|
||||
import { STATUS_CODE } from "../server.ts";
|
||||
import {
|
||||
assertNotSelector,
|
||||
assertSelector,
|
||||
@@ -66,7 +66,7 @@ Deno.test("preact/debug is active in dev mode", async () => {
|
||||
// SSR error is shown
|
||||
const resp = await server.get("/");
|
||||
await resp.text(); // Consume
|
||||
assertEquals(resp.status, Status.InternalServerError);
|
||||
assertEquals(resp.status, STATUS_CODE.InternalServerError);
|
||||
|
||||
const { title } = await getErrorOverlay(server, "/");
|
||||
assertStringIncludes(title, "Objects are not valid as a child");
|
||||
@@ -143,12 +143,18 @@ Deno.test("serve client script source map", async () => {
|
||||
const res = await server.get(`/_frsh/fresh_dev_client.js`);
|
||||
await res.text(); // Consume body
|
||||
assertEquals(res.status, 200);
|
||||
assertEquals(res.headers.get("Content-Type"), "application/javascript");
|
||||
assertEquals(
|
||||
res.headers.get("Content-Type"),
|
||||
"application/javascript; charset=UTF-8",
|
||||
);
|
||||
|
||||
const res2 = await server.get(`/_frsh/fresh_dev_client.js.map`);
|
||||
const json = await res2.json();
|
||||
assertEquals(res2.status, 200);
|
||||
assertEquals(res2.headers.get("Content-Type"), "application/json");
|
||||
assertEquals(
|
||||
res2.headers.get("Content-Type"),
|
||||
"application/json; charset=UTF-8",
|
||||
);
|
||||
assert(typeof json.mappings, "string");
|
||||
},
|
||||
);
|
||||
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
import { Status } from "../server.ts";
|
||||
import { STATUS_CODE } from "../server.ts";
|
||||
import { assertEquals, assertStringIncludes } from "./deps.ts";
|
||||
import { getErrorOverlay, withFakeServe } from "./test_utils.ts";
|
||||
|
||||
Deno.test("error page rendered", async () => {
|
||||
await withFakeServe("./tests/fixture_error/dev.ts", async (server) => {
|
||||
const resp = await server.get("/");
|
||||
assertEquals(resp.status, Status.InternalServerError);
|
||||
assertEquals(resp.status, STATUS_CODE.InternalServerError);
|
||||
assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
|
||||
await resp.text(); // Consume
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"preact/": "https://esm.sh/preact@10.15.1/",
|
||||
"@preact/signals": "https://esm.sh/*@preact/signals@1.1.3",
|
||||
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.2.3",
|
||||
"$std/": "https://deno.land/std@0.205.0/"
|
||||
"$std/": "https://deno.land/std@0.208.0/"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
import * as path from "$std/path/mod.ts";
|
||||
import { Status } from "../src/server/deps.ts";
|
||||
import { STATUS_CODE } from "../src/server/deps.ts";
|
||||
import {
|
||||
assert,
|
||||
assertEquals,
|
||||
@@ -110,7 +110,7 @@ Deno.test({
|
||||
// Access the root page
|
||||
const res = await fetch(address);
|
||||
await res.body?.cancel();
|
||||
assertEquals(res.status, Status.OK);
|
||||
assertEquals(res.status, STATUS_CODE.OK);
|
||||
|
||||
// verify the island is revived.
|
||||
const browser = await puppeteer.launch({
|
||||
@@ -201,7 +201,7 @@ Deno.test({
|
||||
// Access the root page
|
||||
const res = await fetch(address);
|
||||
await res.body?.cancel();
|
||||
assertEquals(res.status, Status.OK);
|
||||
assertEquals(res.status, STATUS_CODE.OK);
|
||||
|
||||
// verify the island is revived.
|
||||
const browser = await puppeteer.launch({ args: ["--no-sandbox"] });
|
||||
|
||||
+57
-57
@@ -1,4 +1,4 @@
|
||||
import { ServerContext, Status } from "../server.ts";
|
||||
import { ServerContext, STATUS_CODE } from "../server.ts";
|
||||
import {
|
||||
assert,
|
||||
assertEquals,
|
||||
@@ -28,7 +28,7 @@ const handler = ctx.handler();
|
||||
Deno.test("/ page prerender", async () => {
|
||||
const resp = await handler(new Request("https://fresh.deno.dev/"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
|
||||
assertEquals(resp.headers.get("server"), "fresh test server");
|
||||
const body = await resp.text();
|
||||
@@ -55,7 +55,7 @@ Deno.test("/ page prerender", async () => {
|
||||
Deno.test("/props/123 page prerender", async () => {
|
||||
const resp = await handler(new Request("https://fresh.deno.dev/props/123"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
|
||||
const body = await resp.text();
|
||||
const doc = parseHtml(body);
|
||||
@@ -72,7 +72,7 @@ Deno.test("/props/123 page prerender", async () => {
|
||||
Deno.test("/greet/[name] page prerender", async () => {
|
||||
const resp = await handler(new Request("https://fresh.deno.dev/bar"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, "<div>Hello bar</div>");
|
||||
@@ -84,7 +84,7 @@ Deno.test("/api/head_override - HEAD", async () => {
|
||||
});
|
||||
const resp = await handler(req);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.NoContent);
|
||||
assertEquals(resp.status, STATUS_CODE.NoContent);
|
||||
assertEquals(resp.body, null);
|
||||
assertEquals(
|
||||
resp.headers.get("content-type"),
|
||||
@@ -98,7 +98,7 @@ Deno.test("/api/get_only - HEAD fallback", async () => {
|
||||
});
|
||||
const resp = await handler(req);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
assertEquals(resp.body, null);
|
||||
assertEquals(
|
||||
resp.headers.get("content-type"),
|
||||
@@ -112,7 +112,7 @@ Deno.test("/intercept - GET html", async () => {
|
||||
});
|
||||
const resp = await handler(req);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, "<div>This is HTML</div>");
|
||||
});
|
||||
@@ -123,7 +123,7 @@ Deno.test("/intercept - GET text", async () => {
|
||||
});
|
||||
const resp = await handler(req);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertEquals(body, "This is plain text");
|
||||
});
|
||||
@@ -134,7 +134,7 @@ Deno.test("/intercept - POST", async () => {
|
||||
});
|
||||
const resp = await handler(req);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertEquals(body, "POST response");
|
||||
});
|
||||
@@ -145,7 +145,7 @@ Deno.test("/intercept - DELETE", async () => {
|
||||
});
|
||||
const resp = await handler(req);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.MethodNotAllowed);
|
||||
assertEquals(resp.status, STATUS_CODE.MethodNotAllowed);
|
||||
});
|
||||
|
||||
Deno.test("/intercept_args - GET html", async () => {
|
||||
@@ -154,7 +154,7 @@ Deno.test("/intercept_args - GET html", async () => {
|
||||
});
|
||||
const resp = await handler(req);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, "<div>intercepted</div>");
|
||||
});
|
||||
@@ -165,7 +165,7 @@ Deno.test("/status_overwrite", async () => {
|
||||
});
|
||||
const resp = await handler(req);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.Unauthorized);
|
||||
assertEquals(resp.status, STATUS_CODE.Unauthorized);
|
||||
assertEquals(resp.headers.get("x-some-header"), "foo");
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, "<div>This is HTML</div>");
|
||||
@@ -178,13 +178,13 @@ Deno.test("/api/get_only - NOTAMETHOD", async () => {
|
||||
}),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.MethodNotAllowed);
|
||||
assertEquals(resp.status, STATUS_CODE.MethodNotAllowed);
|
||||
});
|
||||
|
||||
Deno.test("/api/xyz not found", async () => {
|
||||
const resp = await handler(new Request("https://fresh.deno.dev/api/xyz"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.NotFound);
|
||||
assertEquals(resp.status, STATUS_CODE.NotFound);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, "404 not found: /api/xyz");
|
||||
});
|
||||
@@ -192,7 +192,7 @@ Deno.test("/api/xyz not found", async () => {
|
||||
Deno.test("/static page prerender", async () => {
|
||||
const resp = await handler(new Request("https://fresh.deno.dev/static"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
|
||||
const body = await resp.text();
|
||||
assert(!body.includes(`main.js`));
|
||||
@@ -205,7 +205,7 @@ Deno.test("/static page prerender", async () => {
|
||||
Deno.test("/books/:id page - /books/123", async () => {
|
||||
const resp = await handler(new Request("https://fresh.deno.dev/books/123"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, "<div>Book 123</div>");
|
||||
@@ -214,13 +214,13 @@ Deno.test("/books/:id page - /books/123", async () => {
|
||||
Deno.test("/books/:id page - /books/abc", async () => {
|
||||
const resp = await handler(new Request("https://fresh.deno.dev/books/abc"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.NotFound);
|
||||
assertEquals(resp.status, STATUS_CODE.NotFound);
|
||||
});
|
||||
|
||||
Deno.test("/i18n{/:lang}?/lang page - /i18n/lang", async () => {
|
||||
const resp = await handler(new Request("https://fresh.deno.dev/i18n/lang"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, "<div>Hello</div>");
|
||||
@@ -231,7 +231,7 @@ Deno.test("/i18n{/:lang}?/lang page - /i18n/en/lang", async () => {
|
||||
new Request("https://fresh.deno.dev/i18n/en/lang"),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, "<div>Hello en</div>");
|
||||
@@ -242,7 +242,7 @@ Deno.test("redirect /pages/fresh/ to /pages/fresh", async () => {
|
||||
new Request("https://fresh.deno.dev/pages/fresh/"),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.TemporaryRedirect);
|
||||
assertEquals(resp.status, STATUS_CODE.TemporaryRedirect);
|
||||
assertEquals(
|
||||
resp.headers.get("location"),
|
||||
"/pages/fresh",
|
||||
@@ -254,7 +254,7 @@ Deno.test("redirect /pages/////fresh///// to /pages/////fresh", async () => {
|
||||
new Request("https://fresh.deno.dev/pages/////fresh/////"),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.TemporaryRedirect);
|
||||
assertEquals(resp.status, STATUS_CODE.TemporaryRedirect);
|
||||
assertEquals(
|
||||
resp.headers.get("location"),
|
||||
"/pages/////fresh",
|
||||
@@ -266,7 +266,7 @@ Deno.test("redirect /pages/////fresh/ to /pages/////fresh", async () => {
|
||||
new Request("https://fresh.deno.dev/pages/////fresh/"),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.TemporaryRedirect);
|
||||
assertEquals(resp.status, STATUS_CODE.TemporaryRedirect);
|
||||
assertEquals(
|
||||
resp.headers.get("location"),
|
||||
"/pages/////fresh",
|
||||
@@ -278,13 +278,13 @@ Deno.test("no redirect for /pages/////fresh", async () => {
|
||||
new Request("https://fresh.deno.dev/pages/////fresh"),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.NotFound);
|
||||
assertEquals(resp.status, STATUS_CODE.NotFound);
|
||||
});
|
||||
|
||||
Deno.test("/failure", async () => {
|
||||
const resp = await handler(new Request("https://fresh.deno.dev/failure"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.InternalServerError);
|
||||
assertEquals(resp.status, STATUS_CODE.InternalServerError);
|
||||
const body = await resp.text();
|
||||
assert(body.includes("500 internal error: it errored!"));
|
||||
assertStringIncludes(
|
||||
@@ -296,7 +296,7 @@ Deno.test("/failure", async () => {
|
||||
Deno.test("/foo/:path*", async () => {
|
||||
const resp = await handler(new Request("https://fresh.deno.dev/foo/bar/baz"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assert(body.includes("bar/baz"));
|
||||
});
|
||||
@@ -319,14 +319,14 @@ Deno.test("static files in custom directory", async () => {
|
||||
const resp = await newRouter(
|
||||
new Request("https://fresh.deno.dev/custom.txt"),
|
||||
);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assert(body.startsWith("dir"));
|
||||
});
|
||||
|
||||
Deno.test("static file - by file path", async () => {
|
||||
const resp = await handler(new Request("https://fresh.deno.dev/foo.txt"));
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assert(body.startsWith("bar"));
|
||||
const etag = resp.headers.get("etag");
|
||||
@@ -334,7 +334,7 @@ Deno.test("static file - by file path", async () => {
|
||||
// The etag is not weak, because this did not go through content encoding, so
|
||||
// this is not a real server.
|
||||
assert(!etag.startsWith("W/"), "etag should be weak");
|
||||
assertEquals(resp.headers.get("content-type"), "text/plain");
|
||||
assertEquals(resp.headers.get("content-type"), "text/plain; charset=UTF-8");
|
||||
|
||||
const resp2 = await handler(
|
||||
new Request("https://fresh.deno.dev/foo.txt", {
|
||||
@@ -343,9 +343,9 @@ Deno.test("static file - by file path", async () => {
|
||||
},
|
||||
}),
|
||||
);
|
||||
assertEquals(resp2.status, Status.NotModified);
|
||||
assertEquals(resp2.status, STATUS_CODE.NotModified);
|
||||
assertEquals(resp2.headers.get("etag"), etag);
|
||||
assertEquals(resp2.headers.get("content-type"), "text/plain");
|
||||
assertEquals(resp2.headers.get("content-type"), "text/plain; charset=UTF-8");
|
||||
|
||||
const resp3 = await handler(
|
||||
new Request("https://fresh.deno.dev/foo.txt", {
|
||||
@@ -354,9 +354,9 @@ Deno.test("static file - by file path", async () => {
|
||||
},
|
||||
}),
|
||||
);
|
||||
assertEquals(resp3.status, Status.NotModified);
|
||||
assertEquals(resp3.status, STATUS_CODE.NotModified);
|
||||
assertEquals(resp3.headers.get("etag"), etag);
|
||||
assertEquals(resp3.headers.get("content-type"), "text/plain");
|
||||
assertEquals(resp3.headers.get("content-type"), "text/plain; charset=UTF-8");
|
||||
});
|
||||
|
||||
Deno.test("static file - spaces or other characters in name", async () => {
|
||||
@@ -376,7 +376,7 @@ Deno.test("HEAD request", async () => {
|
||||
method: "HEAD",
|
||||
}),
|
||||
);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertEquals(body, "");
|
||||
|
||||
@@ -387,7 +387,7 @@ Deno.test("HEAD request", async () => {
|
||||
}),
|
||||
);
|
||||
assert(resp2);
|
||||
assertEquals(resp2.status, Status.OK);
|
||||
assertEquals(resp2.status, STATUS_CODE.OK);
|
||||
const body2 = await resp2.text();
|
||||
assertEquals(body2, "");
|
||||
});
|
||||
@@ -407,7 +407,7 @@ Deno.test("static file - by 'hashed' path", async () => {
|
||||
new Request(`https://fresh.deno.dev${imgFilePath}`),
|
||||
);
|
||||
const _ = await resp2.text();
|
||||
assertEquals(resp2.status, Status.OK);
|
||||
assertEquals(resp2.status, STATUS_CODE.OK);
|
||||
assertEquals(
|
||||
resp2.headers.get("cache-control"),
|
||||
"public, max-age=31536000, immutable",
|
||||
@@ -420,7 +420,7 @@ Deno.test("static file - by 'hashed' path", async () => {
|
||||
},
|
||||
}),
|
||||
);
|
||||
assertEquals(resp3.status, Status.NotModified);
|
||||
assertEquals(resp3.status, STATUS_CODE.NotModified);
|
||||
|
||||
// ensure asset hook is not applied on file explicitly excluded with attribute
|
||||
const imgFilePathWithNoCache = body.match(
|
||||
@@ -459,7 +459,7 @@ Deno.test("/params/:path*", async () => {
|
||||
new Request("https://fresh.deno.dev/params/bar/baz"),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertEquals(body, "bar/baz");
|
||||
});
|
||||
@@ -467,7 +467,7 @@ Deno.test("/params/:path*", async () => {
|
||||
Deno.test("/connInfo", async () => {
|
||||
const resp = await handler(new Request("https://fresh.deno.dev/connInfo"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertEquals(body, "localhost");
|
||||
});
|
||||
@@ -477,7 +477,7 @@ Deno.test("state in page props", async () => {
|
||||
new Request("https://fresh.deno.dev/state-in-props"),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(
|
||||
@@ -495,7 +495,7 @@ Deno.test({
|
||||
new Request("https://fresh.deno.dev/middleware_root"),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, "root_mw");
|
||||
assert(!body.includes("layer1_mw"));
|
||||
@@ -513,7 +513,7 @@ Deno.test({
|
||||
assert(resp);
|
||||
|
||||
// test cors handler
|
||||
assertEquals(resp.status, Status.NoContent);
|
||||
assertEquals(resp.status, STATUS_CODE.NoContent);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -524,7 +524,7 @@ Deno.test({
|
||||
new Request("https://fresh.deno.dev/middleware_root"),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
|
||||
// test log handler
|
||||
const latency = resp.headers.get("latency");
|
||||
@@ -540,7 +540,7 @@ Deno.test({
|
||||
new Request("https://fresh.deno.dev/layeredMdw/layer2/abc"),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, "root_mw");
|
||||
assertStringIncludes(body, "layer1_mw");
|
||||
@@ -552,7 +552,7 @@ Deno.test({
|
||||
new Request("https://fresh.deno.dev/layeredMdw/layer2-no-mw/without_mw"),
|
||||
);
|
||||
assert(resp1);
|
||||
assertEquals(resp1.status, Status.OK);
|
||||
assertEquals(resp1.status, STATUS_CODE.OK);
|
||||
const body1 = await resp1.text();
|
||||
assertStringIncludes(body1, "root_mw");
|
||||
assertStringIncludes(body1, "layer1_mw");
|
||||
@@ -569,7 +569,7 @@ Deno.test({
|
||||
new Request("https://fresh.deno.dev/layeredMdw/layer2"),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, "root_mw");
|
||||
assertStringIncludes(body, "layer1_mw");
|
||||
@@ -581,7 +581,7 @@ Deno.test({
|
||||
new Request("https://fresh.deno.dev/layeredMdw/layer2-no-mw/without_mw"),
|
||||
);
|
||||
assert(resp1);
|
||||
assertEquals(resp1.status, Status.OK);
|
||||
assertEquals(resp1.status, STATUS_CODE.OK);
|
||||
const body1 = await resp1.text();
|
||||
assertStringIncludes(body1, "root_mw");
|
||||
assertStringIncludes(body1, "layer1_mw");
|
||||
@@ -599,7 +599,7 @@ Deno.test({
|
||||
new Request("https://fresh.deno.dev/layeredMdw/layer2/layer3/abc"),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, "root_mw");
|
||||
assertStringIncludes(body, "layer1_mw");
|
||||
@@ -619,7 +619,7 @@ Deno.test({
|
||||
new Request("https://fresh.deno.dev/state-middleware/foo"),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
|
||||
const body = await resp.text();
|
||||
const doc = parseHtml(body);
|
||||
@@ -640,7 +640,7 @@ Deno.test({
|
||||
),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const _body = await resp.text();
|
||||
// assert that outer has access to all params
|
||||
assertEquals(
|
||||
@@ -665,7 +665,7 @@ Deno.test({
|
||||
),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, "<div>1234</div>");
|
||||
},
|
||||
@@ -716,7 +716,7 @@ Deno.test({
|
||||
),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.InternalServerError);
|
||||
assertEquals(resp.status, STATUS_CODE.InternalServerError);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(
|
||||
body,
|
||||
@@ -734,7 +734,7 @@ Deno.test({
|
||||
),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.NotFound);
|
||||
assertEquals(resp.status, STATUS_CODE.NotFound);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(
|
||||
body,
|
||||
@@ -752,7 +752,7 @@ Deno.test({
|
||||
),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.NotFound);
|
||||
assertEquals(resp.status, STATUS_CODE.NotFound);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(
|
||||
body,
|
||||
@@ -770,7 +770,7 @@ Deno.test({
|
||||
),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.NotFound);
|
||||
assertEquals(resp.status, STATUS_CODE.NotFound);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(
|
||||
body,
|
||||
@@ -789,7 +789,7 @@ Deno.test("jsx pragma works", async (t) => {
|
||||
|
||||
await t.step("ssr", async () => {
|
||||
const resp = await fetch(address);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const text = await resp.text();
|
||||
assertStringIncludes(text, "Hello World");
|
||||
assertStringIncludes(text, "ssr");
|
||||
@@ -877,7 +877,7 @@ Deno.test("PORT environment variable", async () => {
|
||||
const resp = await fetch("http://localhost:" + PORT);
|
||||
await resp.body?.cancel();
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
await resp.body!.cancel();
|
||||
|
||||
serverProcess.kill("SIGTERM");
|
||||
@@ -907,7 +907,7 @@ Deno.test("rendering custom _500.tsx page for default handlers", async (t) => {
|
||||
await withFakeServe("./tests/fixture_custom_500/main.ts", async (server) => {
|
||||
await t.step("SSR error is shown", async () => {
|
||||
const resp = await server.get("/");
|
||||
assertEquals(resp.status, Status.InternalServerError);
|
||||
assertEquals(resp.status, STATUS_CODE.InternalServerError);
|
||||
const text = await resp.text();
|
||||
assertStringIncludes(text, "Custom 500: Pickle Rick!");
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ServerContext, Status } from "../server.ts";
|
||||
import { ServerContext, STATUS_CODE } from "../server.ts";
|
||||
import {
|
||||
assert,
|
||||
assertEquals,
|
||||
@@ -33,7 +33,7 @@ const router = (req: Request) => {
|
||||
Deno.test("/static page prerender", async () => {
|
||||
const resp = await router(new Request("https://fresh.deno.dev/static"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, '<style id="abc">body { color: red; }</style>');
|
||||
assert(!body.includes(`>{"v":[[],[]]}</script>`));
|
||||
@@ -52,7 +52,7 @@ Deno.test("/static page prerender", async () => {
|
||||
Deno.test("/with-island prerender", async () => {
|
||||
const resp = await router(new Request("https://fresh.deno.dev/with-island"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(
|
||||
body,
|
||||
@@ -69,7 +69,7 @@ Deno.test("/with-island prerender", async () => {
|
||||
Deno.test("plugin routes and middleware", async () => {
|
||||
const resp = await router(new Request("https://fresh.deno.dev/test"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(
|
||||
body,
|
||||
@@ -86,7 +86,7 @@ Deno.test("plugin middleware multiple handlers", async () => {
|
||||
new Request("https://fresh.deno.dev/lots-of-middleware"),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(
|
||||
body,
|
||||
@@ -99,7 +99,7 @@ Deno.test("plugin route no leading slash", async () => {
|
||||
new Request("https://fresh.deno.dev/no-leading-slash-here"),
|
||||
);
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(
|
||||
body,
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
withFresh,
|
||||
withPageName,
|
||||
} from "./test_utils.ts";
|
||||
import { Status } from "../server.ts";
|
||||
import { STATUS_CODE } from "../server.ts";
|
||||
|
||||
Deno.test({
|
||||
name: "render async server component",
|
||||
@@ -110,7 +110,7 @@ Deno.test({
|
||||
async (server) => {
|
||||
const res = await server.get(`/fail`);
|
||||
|
||||
assertEquals(res.status, Status.NotFound);
|
||||
assertEquals(res.status, STATUS_CODE.NotFound);
|
||||
const html = await res.text();
|
||||
assertEquals(html, "Not found.");
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { INTERNAL_PREFIX } from "../runtime.ts";
|
||||
import { ServerContext, Status } from "../server.ts";
|
||||
import { ServerContext, STATUS_CODE } from "../server.ts";
|
||||
import { assert, assertEquals } from "./deps.ts";
|
||||
import manifest from "./fixture_router/fresh.gen.ts";
|
||||
|
||||
@@ -22,7 +22,7 @@ Deno.test("forwards slash placed at the end of url", async () => {
|
||||
const targetUrl = "https://fresh.deno.dev/about";
|
||||
const resp = await router(new Request(targetUrl));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.PermanentRedirect);
|
||||
assertEquals(resp.status, STATUS_CODE.PermanentRedirect);
|
||||
// forwarded location should be with trailing slash
|
||||
assertEquals(resp.headers.get("location"), targetUrl + "/");
|
||||
});
|
||||
@@ -32,7 +32,7 @@ Deno.test("forwards slash placed at the end of url with hash and query string",
|
||||
const queryAndHash = "?demo=test#what";
|
||||
const resp = await router(new Request(targetUrl + queryAndHash));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.PermanentRedirect);
|
||||
assertEquals(resp.status, STATUS_CODE.PermanentRedirect);
|
||||
// forwarded location should be with trailing slash
|
||||
assertEquals(resp.headers.get("location"), targetUrl + "/" + queryAndHash);
|
||||
});
|
||||
@@ -42,7 +42,7 @@ Deno.test("forwards slash not placed at the end of url with prefix", async () =>
|
||||
const resp = await router(new Request(targetUrl));
|
||||
assert(resp);
|
||||
// we should get a 404 and not a redirect
|
||||
assertEquals(resp.status, Status.NotFound);
|
||||
assertEquals(resp.status, STATUS_CODE.NotFound);
|
||||
});
|
||||
|
||||
Deno.test("forwards slash not placed at the end of url for static file", async () => {
|
||||
@@ -50,6 +50,6 @@ Deno.test("forwards slash not placed at the end of url for static file", async (
|
||||
const resp = await router(new Request(targetUrl));
|
||||
assert(resp);
|
||||
// we should not be getting a redirect
|
||||
assertEquals(resp.status, Status.OK);
|
||||
assertEquals(resp.status, STATUS_CODE.OK);
|
||||
assertEquals(await resp.text(), "bar");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user