fix: middleware regressions (#3106)
Fixes some regressions found after merging https://github.com/denoland/fresh/pull/3086 - Missing 404 middlewares when mounting sub-apps - revert more staticFiles logic to always require the middleware like before
This commit is contained in:
@@ -412,6 +412,29 @@ Deno.test(
|
||||
},
|
||||
);
|
||||
|
||||
Deno.test("App - .mountApp() fallback route", async () => {
|
||||
let called = "";
|
||||
const innerApp = new App<{ text: string }>()
|
||||
.use(function Inner(ctx) {
|
||||
called += "_Inner";
|
||||
return ctx.next();
|
||||
})
|
||||
.get("/", (ctx) => new Response(ctx.state.text));
|
||||
|
||||
const app = new App<{ text: string }>()
|
||||
.use(function Outer(ctx) {
|
||||
called += "Outer";
|
||||
return ctx.next();
|
||||
})
|
||||
.mountApp("/", innerApp);
|
||||
|
||||
const server = new FakeServer(app.handler());
|
||||
|
||||
const res = await server.get("/invalid");
|
||||
await res.body?.cancel();
|
||||
expect(called).toEqual("Outer_Inner");
|
||||
});
|
||||
|
||||
Deno.test("App - catches errors", async () => {
|
||||
let thrownErr: unknown | null = null;
|
||||
const app = new App<{ text: string }>()
|
||||
|
||||
Reference in New Issue
Block a user