1- import { serveInternalStaticFiles } from "./static_files.ts" ;
1+ import { staticFiles } from "./static_files.ts" ;
22import { serveMiddleware } from "../test_utils.ts" ;
33import type { BuildCache , StaticFile } from "../build_cache.ts" ;
44import { expect } from "@std/expect" ;
@@ -39,7 +39,7 @@ Deno.test("static files - 200", async () => {
3939 "foo.css" : { content : "body {}" , hash : null } ,
4040 } ) ;
4141 const server = serveMiddleware (
42- serveInternalStaticFiles ( ) ,
42+ staticFiles ( ) ,
4343 { buildCache } ,
4444 ) ;
4545
@@ -59,7 +59,7 @@ Deno.test("static files - HEAD 200", async () => {
5959 "foo.css" : { content : "body {}" , hash : null } ,
6060 } ) ;
6161 const server = serveMiddleware (
62- serveInternalStaticFiles ( ) ,
62+ staticFiles ( ) ,
6363 { buildCache } ,
6464 ) ;
6565
@@ -76,7 +76,7 @@ Deno.test("static files - etag", async () => {
7676 "foo.css" : { content : "body {}" , hash : "123" } ,
7777 } ) ;
7878 const server = serveMiddleware (
79- serveInternalStaticFiles ( ) ,
79+ staticFiles ( ) ,
8080 { buildCache } ,
8181 ) ;
8282
@@ -101,7 +101,7 @@ Deno.test("static files - etag", async () => {
101101Deno . test ( "static files - 404 on missing favicon.ico" , async ( ) => {
102102 const buildCache = new MockBuildCache ( { } ) ;
103103 const server = serveMiddleware (
104- serveInternalStaticFiles ( ) ,
104+ staticFiles ( ) ,
105105 { buildCache } ,
106106 ) ;
107107 const res = await server . get ( "favicon.ico" ) ;
@@ -114,7 +114,7 @@ Deno.test("static files - 405 on wrong HTTP method", async () => {
114114 "foo.css" : { content : "body {}" , hash : null } ,
115115 } ) ;
116116 const server = serveMiddleware (
117- serveInternalStaticFiles ( ) ,
117+ staticFiles ( ) ,
118118 { buildCache } ,
119119 ) ;
120120
@@ -131,7 +131,7 @@ Deno.test("static files - disables caching in development", async () => {
131131 "foo.css" : { content : "body {}" , hash : null } ,
132132 } ) ;
133133 const server = serveMiddleware (
134- serveInternalStaticFiles ( ) ,
134+ staticFiles ( ) ,
135135 {
136136 buildCache,
137137 config : {
@@ -159,7 +159,7 @@ Deno.test("static files - enables caching in production", async () => {
159159 "foo.css" : { content : "body {}" , hash : null } ,
160160 } ) ;
161161 const server = serveMiddleware (
162- serveInternalStaticFiles ( ) ,
162+ staticFiles ( ) ,
163163 {
164164 buildCache,
165165 config : {
@@ -189,7 +189,7 @@ Deno.test("static files - decoded pathname", async () => {
189189 "인천.avif" : { content : "body {}" , hash : null } ,
190190 } ) ;
191191 const server = serveMiddleware (
192- serveInternalStaticFiles ( ) ,
192+ staticFiles ( ) ,
193193 { buildCache } ,
194194 ) ;
195195
@@ -205,3 +205,22 @@ Deno.test("static files - decoded pathname", async () => {
205205 expect ( res . status ) . toEqual ( 200 ) ;
206206 }
207207} ) ;
208+
209+ Deno . test ( "static files - fallthrough" , async ( ) => {
210+ const buildCache = new MockBuildCache ( {
211+ "foo.css" : { content : "body {}" , hash : null } ,
212+ } ) ;
213+
214+ const server = serveMiddleware (
215+ staticFiles ( ) ,
216+ { buildCache, next : ( ) => Promise . resolve ( new Response ( "it works" ) ) } ,
217+ ) ;
218+
219+ let res = await server . get ( "foo.css" ) ;
220+ let text = await res . text ( ) ;
221+ expect ( text ) . toEqual ( "body {}" ) ;
222+
223+ res = await server . get ( "/" ) ;
224+ text = await res . text ( ) ;
225+ expect ( text ) . toEqual ( "it works" ) ;
226+ } ) ;
0 commit comments