chore: restructure repository into packages/ folder (#3197)
We're having a growing number of packages in this repository. This PR moves them into a `packages/` directory like it's commonly done in other projects.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
// deno-lint-ignore-file require-await
|
||||
import { trailingSlashes } from "./trailing_slashes.ts";
|
||||
import { expect } from "@std/expect";
|
||||
import { serveMiddleware } from "../test_utils.ts";
|
||||
|
||||
Deno.test("trailingSlashes - always", async () => {
|
||||
const middleware = trailingSlashes("always");
|
||||
const server = serveMiddleware(middleware, {
|
||||
next: async () => new Response("ok"),
|
||||
});
|
||||
|
||||
let res = await server.get("/");
|
||||
await res.body?.cancel();
|
||||
expect(res.status).toEqual(200);
|
||||
expect(res.headers.get("Location")).toEqual(null);
|
||||
|
||||
res = await server.get("/foo");
|
||||
await res.body?.cancel();
|
||||
expect(res.status).toEqual(302);
|
||||
expect(res.headers.get("Location")).toEqual("/foo/");
|
||||
|
||||
res = await server.get("/foo/bar");
|
||||
await res.body?.cancel();
|
||||
expect(res.status).toEqual(302);
|
||||
expect(res.headers.get("Location")).toEqual("/foo/bar/");
|
||||
|
||||
res = await server.get("/foo/bar/");
|
||||
await res.body?.cancel();
|
||||
expect(res.status).toEqual(200);
|
||||
expect(res.headers.get("Location")).toEqual(null);
|
||||
});
|
||||
|
||||
Deno.test("trailingSlashes - never", async () => {
|
||||
const middleware = trailingSlashes("never");
|
||||
const server = serveMiddleware(middleware, {
|
||||
next: async () => new Response("ok"),
|
||||
});
|
||||
|
||||
let res = await server.get("/");
|
||||
await res.body?.cancel();
|
||||
expect(res.status).toEqual(200);
|
||||
expect(res.headers.get("Location")).toEqual(null);
|
||||
|
||||
res = await server.get("/foo");
|
||||
await res.body?.cancel();
|
||||
expect(res.status).toEqual(200);
|
||||
expect(res.headers.get("Location")).toEqual(null);
|
||||
|
||||
res = await server.get("/foo/");
|
||||
await res.body?.cancel();
|
||||
expect(res.status).toEqual(302);
|
||||
expect(res.headers.get("Location")).toEqual("/foo");
|
||||
});
|
||||
Reference in New Issue
Block a user