Skip to content

Commit dd4c614

Browse files
bartlomiejuclaude
andcommitted
fix: update router tests from main to use new single-item API
Tests added on main used the old array-based router API (handlers: [], router.add(..., [A])). Updated to match the new single-item API (item:, router.add(..., A)) introduced by this PR. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 480fa8e commit dd4c614

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

packages/fresh/src/router_test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ Deno.test("UrlPatternRouter - wrong + correct method", () => {
7373
Deno.test("UrlPatternRouter - trailing slash matches route without slash", () => {
7474
const router = new UrlPatternRouter();
7575
const A = () => {};
76-
router.add("GET", "/wissen", [A]);
76+
router.add("GET", "/wissen", A);
7777

7878
const res = router.match("GET", new URL("/wissen/", "http://localhost"));
7979
expect(res).toEqual({
8080
params: Object.create(null),
81-
handlers: [A],
81+
item: A,
8282
methodMatch: true,
8383
pattern: "/wissen",
8484
});
@@ -87,12 +87,12 @@ Deno.test("UrlPatternRouter - trailing slash matches route without slash", () =>
8787
Deno.test("UrlPatternRouter - no trailing slash matches route with slash", () => {
8888
const router = new UrlPatternRouter();
8989
const A = () => {};
90-
router.add("GET", "/wissen/", [A]);
90+
router.add("GET", "/wissen/", A);
9191

9292
const res = router.match("GET", new URL("/wissen", "http://localhost"));
9393
expect(res).toEqual({
9494
params: Object.create(null),
95-
handlers: [A],
95+
item: A,
9696
methodMatch: true,
9797
pattern: "/wissen/",
9898
});
@@ -102,16 +102,16 @@ Deno.test("UrlPatternRouter - exact match takes priority over trailing slash fal
102102
const router = new UrlPatternRouter();
103103
const A = () => {};
104104
const B = () => {};
105-
router.add("GET", "/wissen", [A]);
106-
router.add("GET", "/wissen/", [B]);
105+
router.add("GET", "/wissen", A);
106+
router.add("GET", "/wissen/", B);
107107

108108
const withSlash = router.match(
109109
"GET",
110110
new URL("/wissen/", "http://localhost"),
111111
);
112112
expect(withSlash).toEqual({
113113
params: Object.create(null),
114-
handlers: [B],
114+
item: B,
115115
methodMatch: true,
116116
pattern: "/wissen/",
117117
});
@@ -122,7 +122,7 @@ Deno.test("UrlPatternRouter - exact match takes priority over trailing slash fal
122122
);
123123
expect(withoutSlash).toEqual({
124124
params: Object.create(null),
125-
handlers: [A],
125+
item: A,
126126
methodMatch: true,
127127
pattern: "/wissen",
128128
});
@@ -131,12 +131,12 @@ Deno.test("UrlPatternRouter - exact match takes priority over trailing slash fal
131131
Deno.test("UrlPatternRouter - root trailing slash does not double-match", () => {
132132
const router = new UrlPatternRouter();
133133
const A = () => {};
134-
router.add("GET", "/", [A]);
134+
router.add("GET", "/", A);
135135

136136
const res = router.match("GET", new URL("/", "http://localhost"));
137137
expect(res).toEqual({
138138
params: Object.create(null),
139-
handlers: [A],
139+
item: A,
140140
methodMatch: true,
141141
pattern: "/",
142142
});

0 commit comments

Comments
 (0)