@@ -751,6 +751,12 @@ test('should respect in-source configuration from edge functions', async (t) =>
751751 handler : ( ) => new Response ( 'Hello world' ) ,
752752 name : 'hello' ,
753753 } )
754+ . withEdgeFunction ( {
755+ config : ( ) => ( { path : '/internal-1' } ) ,
756+ handler : ( ) => new Response ( 'Hello from an internal function' ) ,
757+ internal : true ,
758+ name : 'internal' ,
759+ } )
754760
755761 await builder . buildAsync ( )
756762
@@ -760,6 +766,11 @@ test('should respect in-source configuration from edge functions', async (t) =>
760766 t . is ( res1 . statusCode , 200 )
761767 t . is ( res1 . body , 'Hello world' )
762768
769+ const res2 = await got ( `http://localhost:${ port } /internal-1` , { throwHttpErrors : false } )
770+
771+ t . is ( res2 . statusCode , 200 )
772+ t . is ( res2 . body , 'Hello from an internal function' )
773+
763774 // wait for file watcher to be up and running, which might take a little
764775 // if we do not wait, the next file change will not be picked up
765776 await pause ( 500 )
@@ -770,18 +781,33 @@ test('should respect in-source configuration from edge functions', async (t) =>
770781 handler : ( ) => new Response ( 'Hello world' ) ,
771782 name : 'hello' ,
772783 } )
784+ . withEdgeFunction ( {
785+ config : ( ) => ( { path : '/internal-2' } ) ,
786+ handler : ( ) => new Response ( 'Hello from an internal function' ) ,
787+ internal : true ,
788+ name : 'internal' ,
789+ } )
773790 . buildAsync ( )
774791
775792 await waitForLogMatching ( 'Reloaded edge function' )
776793
777- const res2 = await got ( `http://localhost:${ port } /hello-1` , { throwHttpErrors : false } )
794+ const res3 = await got ( `http://localhost:${ port } /hello-1` , { throwHttpErrors : false } )
795+
796+ t . is ( res3 . statusCode , 404 )
797+
798+ const res4 = await got ( `http://localhost:${ port } /hello-2` , { throwHttpErrors : false } )
799+
800+ t . is ( res4 . statusCode , 200 )
801+ t . is ( res4 . body , 'Hello world' )
802+
803+ const res5 = await got ( `http://localhost:${ port } /internal-1` , { throwHttpErrors : false } )
778804
779- t . is ( res2 . statusCode , 404 )
805+ t . is ( res5 . statusCode , 404 )
780806
781- const res3 = await got ( `http://localhost:${ port } /hello -2` , { throwHttpErrors : false } )
807+ const res6 = await got ( `http://localhost:${ port } /internal -2` , { throwHttpErrors : false } )
782808
783- t . is ( res3 . statusCode , 200 )
784- t . is ( res3 . body , 'Hello world ' )
809+ t . is ( res6 . statusCode , 200 )
810+ t . is ( res6 . body , 'Hello from an internal function ' )
785811 } )
786812 } )
787813} )
0 commit comments