@@ -69,6 +69,23 @@ describe("createLineNodeWebhookHandler", () => {
6969 expect ( res . body ) . toBe ( "OK" ) ;
7070 } ) ;
7171
72+ it ( "returns 204 for HEAD" , async ( ) => {
73+ const bot = { handleWebhook : vi . fn ( async ( ) => { } ) } ;
74+ const runtime = { log : vi . fn ( ) , error : vi . fn ( ) , exit : vi . fn ( ) } ;
75+ const handler = createLineNodeWebhookHandler ( {
76+ channelSecret : "secret" ,
77+ bot,
78+ runtime,
79+ readBody : async ( ) => "" ,
80+ } ) ;
81+
82+ const { res } = createRes ( ) ;
83+ await handler ( { method : "HEAD" , headers : { } } as unknown as IncomingMessage , res ) ;
84+
85+ expect ( res . statusCode ) . toBe ( 204 ) ;
86+ expect ( res . body ) . toBeUndefined ( ) ;
87+ } ) ;
88+
7289 it ( "returns 200 for verification request (empty events, no signature)" , async ( ) => {
7390 const rawBody = JSON . stringify ( { events : [ ] } ) ;
7491 const { bot, handler } = createPostWebhookTestHarness ( rawBody ) ;
@@ -82,14 +99,14 @@ describe("createLineNodeWebhookHandler", () => {
8299 expect ( bot . handleWebhook ) . not . toHaveBeenCalled ( ) ;
83100 } ) ;
84101
85- it ( "returns 405 for non-GET/non- POST methods" , async ( ) => {
102+ it ( "returns 405 for non-GET/HEAD/ POST methods" , async ( ) => {
86103 const { bot, handler } = createPostWebhookTestHarness ( JSON . stringify ( { events : [ ] } ) ) ;
87104
88105 const { res, headers } = createRes ( ) ;
89106 await handler ( { method : "PUT" , headers : { } } as unknown as IncomingMessage , res ) ;
90107
91108 expect ( res . statusCode ) . toBe ( 405 ) ;
92- expect ( headers . allow ) . toBe ( "GET, POST" ) ;
109+ expect ( headers . allow ) . toBe ( "GET, HEAD, POST" ) ;
93110 expect ( bot . handleWebhook ) . not . toHaveBeenCalled ( ) ;
94111 } ) ;
95112
0 commit comments