-
Notifications
You must be signed in to change notification settings - Fork 2
/
router.test.ts
45 lines (40 loc) · 1.08 KB
/
router.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
43
44
45
// Copyright 2018-2024 the oak authors. All rights reserved.
import { assert } from "jsr:@std/assert@^0.226/assert";
import { Router } from "./router.ts";
import { assertEquals } from "jsr:@std/assert@^0.226/assert-equals";
Deno.test({
name: "Router - register route - get - path and handler",
fn() {
const router = new Router();
router.get("/", () => {
return { hello: "world" };
});
const route = router.match("GET", "/");
assert(route);
assertEquals(route.path, "/");
},
});
Deno.test({
name: "Router - register route - head - path and handler",
fn() {
const router = new Router();
router.head("/", () => {
return { hello: "world" };
});
const route = router.match("HEAD", "/");
assert(route);
assertEquals(route.path, "/");
},
});
Deno.test({
name: "Router - register route - post - path and handler",
fn() {
const router = new Router();
router.post("/", () => {
return { hello: "world" };
});
const route = router.match("POST", "/");
assert(route);
assertEquals(route.path, "/");
},
});