@@ -141,7 +141,6 @@ describe('Static Plugin', () => {
141141 const app = new Elysia ( ) . use (
142142 staticPlugin ( {
143143 alwaysStatic : true ,
144- prefix : '' ,
145144 assets : join ( import . meta. dir , '../public' )
146145 } )
147146 )
@@ -390,48 +389,56 @@ describe('Static Plugin', () => {
390389 } )
391390
392391 it ( 'serve index.html to default /' , async ( ) => {
393- let app = new Elysia ( ) . use ( staticPlugin ( ) )
392+ const app = new Elysia ( ) . use ( staticPlugin ( ) )
394393 await app . modules
395394
396395 let res = await app . handle ( req ( '/public' ) )
397396 expect ( res . status ) . toBe ( 404 )
398397
399398 res = await app . handle ( req ( '/public/html' ) )
400399 expect ( res . status ) . toBe ( 200 )
400+ } )
401401
402- app = new Elysia ( ) . use (
402+ it ( 'does not serve index.html to default / when not indexHTML' , async ( ) => {
403+ const app = new Elysia ( ) . use (
403404 staticPlugin ( {
404405 indexHTML : false
405406 } )
406407 )
408+ await app . modules
407409
408- res = await app . handle ( req ( '/public' ) )
410+ let res = await app . handle ( req ( '/public' ) )
409411 expect ( res . status ) . toBe ( 404 )
410412
411413 res = await app . handle ( req ( '/public/html' ) )
412414 expect ( res . status ) . toBe ( 404 )
415+ } )
413416
414- // Not sure why this error but not in dev environment
415- // app = new Elysia().use(
416- // staticPlugin({
417- // alwaysStatic: true
418- // })
419- // )
417+ it ( 'serves index.html to default / when alwaysStatic' , async ( ) => {
418+ const app = new Elysia ( ) . use (
419+ staticPlugin ( {
420+ alwaysStatic : true
421+ } )
422+ )
423+ await app . modules
420424
421- // res = await app.handle(req('/public'))
422- // expect(res.status).toBe(404)
425+ let res = await app . handle ( req ( '/public' ) )
426+ expect ( res . status ) . toBe ( 404 )
423427
424- // res = await app.handle(req('/public/html'))
425- // expect(res.status).toBe(200)
428+ res = await app . handle ( req ( '/public/html' ) )
429+ expect ( res . status ) . toBe ( 200 )
430+ } )
426431
427- app = new Elysia ( ) . use (
432+ it ( 'does not serve index.html to default / when alwaysStatic and not indexHTML' , async ( ) => {
433+ const app = new Elysia ( ) . use (
428434 staticPlugin ( {
429435 alwaysStatic : true ,
430436 indexHTML : false
431437 } )
432438 )
439+ await app . modules
433440
434- res = await app . handle ( req ( '/public' ) )
441+ let res = await app . handle ( req ( '/public' ) )
435442 expect ( res . status ) . toBe ( 404 )
436443
437444 res = await app . handle ( req ( '/public/html' ) )
0 commit comments