@@ -751,6 +751,12 @@ test('should respect in-source configuration from edge functions', async (t) =>
751
751
handler : ( ) => new Response ( 'Hello world' ) ,
752
752
name : 'hello' ,
753
753
} )
754
+ . withEdgeFunction ( {
755
+ config : ( ) => ( { path : '/internal-1' } ) ,
756
+ handler : ( ) => new Response ( 'Hello from an internal function' ) ,
757
+ internal : true ,
758
+ name : 'internal' ,
759
+ } )
754
760
755
761
await builder . buildAsync ( )
756
762
@@ -760,6 +766,11 @@ test('should respect in-source configuration from edge functions', async (t) =>
760
766
t . is ( res1 . statusCode , 200 )
761
767
t . is ( res1 . body , 'Hello world' )
762
768
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
+
763
774
// wait for file watcher to be up and running, which might take a little
764
775
// if we do not wait, the next file change will not be picked up
765
776
await pause ( 500 )
@@ -770,18 +781,33 @@ test('should respect in-source configuration from edge functions', async (t) =>
770
781
handler : ( ) => new Response ( 'Hello world' ) ,
771
782
name : 'hello' ,
772
783
} )
784
+ . withEdgeFunction ( {
785
+ config : ( ) => ( { path : '/internal-2' } ) ,
786
+ handler : ( ) => new Response ( 'Hello from an internal function' ) ,
787
+ internal : true ,
788
+ name : 'internal' ,
789
+ } )
773
790
. buildAsync ( )
774
791
775
792
await waitForLogMatching ( 'Reloaded edge function' )
776
793
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 } )
778
804
779
- t . is ( res2 . statusCode , 404 )
805
+ t . is ( res5 . statusCode , 404 )
780
806
781
- const res3 = await got ( `http://localhost:${ port } /hello -2` , { throwHttpErrors : false } )
807
+ const res6 = await got ( `http://localhost:${ port } /internal -2` , { throwHttpErrors : false } )
782
808
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 ' )
785
811
} )
786
812
} )
787
813
} )
0 commit comments