@@ -90,7 +90,7 @@ describe("Server", () => {
9090 expect ( httpListenSpy ) . toHaveBeenCalledWith ( port , expect . any ( Function ) ) ;
9191 } ) ;
9292
93- test ( "Should create server with custom parsers, logger, error handler and beforeRouting " , async ( ) => {
93+ test ( "Should create server with custom parsers, logger, error handler and hooks " , async ( ) => {
9494 const customLogger = new BuiltinLogger ( { level : "silent" } ) ;
9595 const infoMethod = vi . spyOn ( customLogger , "info" ) ;
9696 const port = givePort ( ) ;
@@ -101,6 +101,7 @@ describe("Server", () => {
101101 rawParser : vi . fn ( ) ,
102102 formParser : vi . fn ( ) ,
103103 beforeRouting : vi . fn ( ) ,
104+ afterRouting : vi . fn ( ) ,
104105 cors : true ,
105106 startupLogo : false ,
106107 errorHandler : {
@@ -147,10 +148,12 @@ describe("Server", () => {
147148 ) ;
148149 expect ( appMock . use ) . toHaveBeenCalledTimes ( 2 ) ;
149150 expect ( configMock . errorHandler . handler ) . toHaveBeenCalledTimes ( 0 ) ;
150- expect ( configMock . beforeRouting ) . toHaveBeenCalledWith ( {
151- app : appMock ,
152- getLogger : expect . any ( Function ) ,
153- } ) ;
151+ for ( const hook of [ "beforeRouting" , "afterRouting" ] as const ) {
152+ expect ( configMock [ hook ] ) . toHaveBeenCalledWith ( {
153+ app : appMock ,
154+ getLogger : expect . any ( Function ) ,
155+ } ) ;
156+ }
154157 expect ( infoMethod ) . toHaveBeenCalledTimes ( 1 ) ;
155158 expect ( infoMethod ) . toHaveBeenCalledWith ( `Listening` , { port } ) ;
156159 expect ( appMock . get ) . toHaveBeenCalledTimes ( 1 ) ;
0 commit comments