File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -647,6 +647,30 @@ describe('disableSSG/onlySSG middlewares', () => {
647647 } )
648648} )
649649
650+ describe ( 'isSSGContext with disableSSG' , ( ) => {
651+ it ( 'Should work correctly when used together' , async ( ) => {
652+ const app = new Hono ( )
653+
654+ app . use ( '*' , async ( c , next ) => {
655+ if ( ! isSSGContext ( c ) ) {
656+ return next ( )
657+ }
658+ await next ( )
659+ } )
660+ app . get ( '/guarded' , disableSSG ( ) , ( c ) => c . html ( '<h1>should be skipped</h1>' ) )
661+ app . get ( '/page' , ( c ) => c . html ( '<h1>hello</h1>' ) )
662+
663+ const fsMock : FileSystemModule = {
664+ writeFile : vi . fn ( ( ) => Promise . resolve ( ) ) ,
665+ mkdir : vi . fn ( ( ) => Promise . resolve ( ) ) ,
666+ }
667+
668+ await expect ( toSSG ( app , fsMock , { dir : './static' } ) ) . resolves . toBeDefined ( )
669+ expect ( fsMock . writeFile ) . toHaveBeenCalledWith ( 'static/page.html' , expect . any ( String ) )
670+ expect ( fsMock . writeFile ) . not . toHaveBeenCalledWith ( 'static/guarded.html' , expect . any ( String ) )
671+ } )
672+ } )
673+
650674describe ( 'Request hooks - filterPathsBeforeRequestHook and denyPathsBeforeRequestHook' , ( ) => {
651675 let app : Hono
652676 let fsMock : FileSystemModule
Original file line number Diff line number Diff line change @@ -229,7 +229,7 @@ export const fetchRoutesContent = function* <
229229 forGetInfoURLRequest = maybeRequest as unknown as AddedSSGDataRequest
230230 }
231231
232- await pool . run ( ( ) => app . fetch ( forGetInfoURLRequest ) )
232+ await pool . run ( ( ) => app . fetch ( forGetInfoURLRequest , { [ SSG_CONTEXT ] : true } ) )
233233
234234 if ( ! forGetInfoURLRequest . ssgParams ) {
235235 if ( isDynamicRoute ( route . path ) ) {
You can’t perform that action at this time.
0 commit comments