forked from denoland/fresh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroute_analysis_test.ts
42 lines (34 loc) · 1.25 KB
/
route_analysis_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { startFreshServerExpectErrors } from "./test_utils.ts";
import { dirname, join } from "$std/path/mod.ts";
import { assertEquals, assertStringIncludes } from "./deps.ts";
import { ServerContext } from "../server.ts";
import manifest from "./fixture/fresh.gen.ts";
const dir = dirname(import.meta.url);
Deno.test({
name: "route-conflicts",
async fn() {
const errorMessage = await startFreshServerExpectErrors({
args: ["run", "-A", join(dir, "./fixture_route_analysis/dev.ts")],
});
assertStringIncludes(
errorMessage,
"Error: Route conflict detected. Multiple files have the same name",
);
},
});
Deno.test("match route parameter and static", async () => {
const handler = (await ServerContext.fromManifest(manifest, {})).handler();
const res = await handler(
new Request("https://fresh.deno.dev/movies/foo.json"),
);
assertEquals(await res.text(), "it works");
assertEquals(res.status, 200);
});
Deno.test("match multiple route parameters", async () => {
const handler = (await ServerContext.fromManifest(manifest, {})).handler();
const res = await handler(
new Request("https://fresh.deno.dev/movies/foo@bar"),
);
assertEquals(await res.text(), "it works");
assertEquals(res.status, 200);
});