Skip to content

Commit

Permalink
Update tesings
Browse files Browse the repository at this point in the history
  • Loading branch information
ije committed Nov 13, 2024
1 parent ad90cd0 commit 3b158db
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions test/fix-urls/test.ts → test/fix-url/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ Deno.test("query as version suffix", async () => {
assertStringIncludes(code, "/[email protected]/es2022/client.development.js");
});

Deno.test("`/jsx-runtime` in query", async () => {
const res = await fetch("http://localhost:8080/[email protected]?dev&target=es2022/jsx-runtime");
const code = await res.text();
assertEquals(res.status, 200);
assertEquals(res.headers.get("cache-control"), "public, max-age=31536000, immutable");
assertEquals(res.headers.get("content-type"), "application/javascript; charset=utf-8");
assert(!res.headers.get("vary")!.includes("User-Agent"));
assertStringIncludes(code, "/[email protected]/es2022/jsx-runtime.development.js");
});

Deno.test("redirect semver versioning module for deno target", async () => {
"deno target";
{
Expand Down Expand Up @@ -60,7 +70,7 @@ Deno.test("redirect asset URLs", async () => {
assertStringIncludes(pkg4.name, "preact");
});

Deno.test("Fix wasm URLs with target segment", async () => {
Deno.test("Fix wasm URLs with `target` segment", async () => {
const res = await fetch(
"http://localhost:8080/[email protected]/deno/lightningcss_node.wasm",
{ redirect: "manual" },
Expand All @@ -84,7 +94,7 @@ Deno.test("Fix wasm URLs with target segment", async () => {
);
});

Deno.test("Fix json URLs with target segment", async () => {
Deno.test("Fix json URLs with `target` segment", async () => {
const res = await fetch(
"http://localhost:8080/[email protected]/deno/package.json",
{ redirect: "manual" },
Expand All @@ -97,13 +107,12 @@ Deno.test("Fix json URLs with target segment", async () => {
);
});

Deno.test("fix `/#/` path", async () => {
const res = await fetch("http://localhost:8080/es5-ext@^0.10.50/string/%23/contains?target=denonext", { redirect: "manual" });
res.body?.cancel();
assertEquals(res.status, 302);
assertEquals(res.headers.get("cache-control"), "public, max-age=3600");
assertStringIncludes(res.headers.get("location")!, "http://localhost:8080/[email protected].");
assertStringIncludes(res.headers.get("location")!, "/string/%23/contains");
Deno.test("support `/#/` in path", async () => {
const res = await fetch("http://localhost:8080/[email protected]/string/%23/contains");
assertEquals(res.status, 200);
assertEquals(res.headers.get("content-type"), "application/javascript; charset=utf-8");
assertEquals(res.headers.get("cache-control"), "public, max-age=31536000, immutable");
assertStringIncludes(await res.text(), "/denonext/string/%23/contains.js");
});

Deno.test("dts-transformer: support `.d` extension", async () => {
Expand Down

0 comments on commit 3b158db

Please sign in to comment.