@@ -60,6 +60,8 @@ vi.mock("../../deps.js", () => ({
6060
6161const { createMessageCliHelpers } = await import ( "./helpers.js" ) ;
6262
63+ const NON_NEGATIVE_INTEGER_FLAGS = new Set ( [ "--delete-days" , "--duration-min" ] ) ;
64+
6365const baseSendOptions = {
6466 channel : "discord" ,
6567 target : "123" ,
@@ -365,7 +367,7 @@ describe("runMessageAction", () => {
365367
366368 await expect ( runMessageAction ( action , opts ) ) . rejects . toThrow ( "exit" ) ;
367369
368- const kind = flag === "--delete-days" ? "non-negative" : "positive" ;
370+ const kind = NON_NEGATIVE_INTEGER_FLAGS . has ( flag ) ? "non-negative" : "positive" ;
369371 expect ( errorMock ) . toHaveBeenCalledWith ( `Error: ${ flag } must be a ${ kind } integer.` ) ;
370372 expect ( ensurePluginRegistryLoaded ) . not . toHaveBeenCalled ( ) ;
371373 expect ( messageCommandMock ) . not . toHaveBeenCalled ( ) ;
@@ -390,7 +392,7 @@ describe("runMessageAction", () => {
390392 } ) ,
391393 ) . rejects . toThrow ( "exit" ) ;
392394
393- const kind = flag === "--delete-days" ? "non-negative" : "positive" ;
395+ const kind = NON_NEGATIVE_INTEGER_FLAGS . has ( flag ) ? "non-negative" : "positive" ;
394396 expect ( errorMock ) . toHaveBeenCalledWith ( `Error: ${ flag } must be a ${ kind } integer.` ) ;
395397 expect ( messageCommandMock ) . not . toHaveBeenCalled ( ) ;
396398 expect ( exitMock ) . toHaveBeenCalledWith ( 1 ) ;
@@ -417,6 +419,27 @@ describe("runMessageAction", () => {
417419 expect ( exitMock ) . toHaveBeenCalledWith ( 0 ) ;
418420 } ) ;
419421
422+ it ( "allows zero duration-min for clearing Discord timeouts" , async ( ) => {
423+ const runMessageAction = createRunMessageAction ( ) ;
424+
425+ await expect (
426+ runMessageAction ( "timeout" , {
427+ guildId : "g" ,
428+ userId : "u" ,
429+ durationMin : "0" ,
430+ } ) ,
431+ ) . rejects . toThrow ( "exit" ) ;
432+
433+ expect ( errorMock ) . not . toHaveBeenCalled ( ) ;
434+ expectMessageCommandOptions ( {
435+ action : "timeout" ,
436+ guildId : "g" ,
437+ userId : "u" ,
438+ durationMin : "0" ,
439+ } ) ;
440+ expect ( exitMock ) . toHaveBeenCalledWith ( 0 ) ;
441+ } ) ;
442+
420443 it ( "runs gateway_stop hooks before exit when registered" , async ( ) => {
421444 hasHooksMock . mockReturnValueOnce ( true ) ;
422445 await runSendAction ( ) ;
0 commit comments