@@ -887,6 +887,44 @@ Deno.test("getEnhancedHandler - not declaring any param", async () => {
887887 assertSpyCalls ( testHandler , 1 ) ;
888888} ) ;
889889
890+ Deno . test ( "getEnhancedHandler - declaring undocumented params" , async ( ) => {
891+ const spyParseOakRequestBody = spy ( _internal , "parseOakReqBody" ) ;
892+ // deno-lint-ignore no-explicit-any
893+ const testHandler = spy ( ( ..._rest : any [ ] ) => 44 ) ;
894+ // deno-lint-ignore ban-types
895+ const enhancedHandler : Function = _internal . getEnhancedHandler (
896+ testHandler ,
897+ "context" as ControllerMethodArg ,
898+ "params" as ControllerMethodArg ,
899+ "queries" as ControllerMethodArg ,
900+ "header" as ControllerMethodArg ,
901+ "hiddenFeature" as ControllerMethodArg ,
902+ ) ;
903+ const ctx = createMockContext ( {
904+ path : "/hello/world" ,
905+ params : { lorem : "undocumented usage" , hiddenFeature : "84" } ,
906+ headers : [ [ "X-Foo" , "Bearer Bar" ] ] ,
907+ } ) ;
908+ Object . defineProperty ( ctx . request , "body" , {
909+ get : ( ) => createMockRequestBody ( "binary" ) ,
910+ } ) ;
911+ Object . defineProperty ( ctx . request . url , "searchParams" , {
912+ value : new Map ( [ [ "ipsum" , "dolor" ] ] ) ,
913+ } ) ;
914+ await enhancedHandler ( ctx ) ;
915+ const [ context , param , query , headers , hiddenFeature ] =
916+ testHandler . calls [ 0 ] . args ;
917+ assertEquals ( param , { lorem : "undocumented usage" , hiddenFeature : "84" } ) ;
918+ assertEquals ( query , { ipsum : "dolor" } ) ;
919+ assertEquals ( hiddenFeature , "84" ) ;
920+ assertEquals ( context , ctx ) ;
921+ assertEquals ( headers , { "x-foo" : "Bearer Bar" } ) ;
922+ assertEquals ( testHandler . calls [ 0 ] . returned , 44 ) ;
923+ assertSpyCalls ( testHandler , 1 ) ;
924+ assertSpyCalls ( spyParseOakRequestBody , 1 ) ;
925+ spyParseOakRequestBody . restore ( ) ;
926+ } ) ;
927+
890928/**
891929 * @NOTE if/when `oak` supports such a method, better import from there instead
892930 */
0 commit comments