@@ -877,3 +877,39 @@ describe('Nested Dynamic Routes', () => {
877
877
expect ( await res . text ( ) ) . toBe ( '<b>Resource2 Id abcdef / 12345</b>' )
878
878
} )
879
879
} )
880
+
881
+ describe ( 'Function Component Response' , ( ) => {
882
+ const ROUTES = import . meta. glob ( '../mocks/app-function/routes/**/[a-z[-][a-z[_-]*.(tsx|ts)' , {
883
+ eager : true ,
884
+ } )
885
+
886
+ const app = createApp ( {
887
+ root : '../mocks/app-function/routes' ,
888
+ ROUTES : ROUTES as any ,
889
+ } )
890
+
891
+ it ( 'Should handle direct Response return from function component' , async ( ) => {
892
+ const res = await app . request ( '/api-response' )
893
+ expect ( res . status ) . toBe ( 200 )
894
+ expect ( await res . json ( ) ) . toEqual ( { message : 'API Response' } )
895
+ } )
896
+
897
+ it ( 'Should handle JSX return from function component' , async ( ) => {
898
+ const res = await app . request ( '/jsx-response' )
899
+ expect ( res . status ) . toBe ( 200 )
900
+ expect ( await res . text ( ) ) . toBe ( '<div>JSX Response</div>' )
901
+ } )
902
+
903
+ it ( 'Should handle async function component with Response' , async ( ) => {
904
+ const res = await app . request ( '/async-response' )
905
+ expect ( res . status ) . toBe ( 201 )
906
+ expect ( res . headers . get ( 'x-custom' ) ) . toBe ( 'async' )
907
+ expect ( await res . json ( ) ) . toEqual ( { message : 'Async Response' } )
908
+ } )
909
+
910
+ it ( 'Should handle async function component with JSX' , async ( ) => {
911
+ const res = await app . request ( '/async-jsx' )
912
+ expect ( res . status ) . toBe ( 200 )
913
+ expect ( await res . text ( ) ) . toBe ( '<div>Async JSX Response</div>' )
914
+ } )
915
+ } )
0 commit comments