@@ -433,6 +433,44 @@ describe("Filter Test", () => {
433433 ) . toBe ( true ) ;
434434 } ) ;
435435
436+ test ( "Non-targeted SET_PARAMS with no output returns false (write-through)" , ( ) => {
437+ const filter = new Filter ( { name : "TargetOnly" } ) ;
438+ const ctrl : FilterControlMessage = {
439+ type : FilterControlMessageType . SET_PARAMS ,
440+ name : "Other" ,
441+ params : { x : 1 } ,
442+ } ;
443+ expect ( filter . write ( ctrl ) ) . toBe ( false ) ;
444+ } ) ;
445+
446+ test ( "Non-targeted SET_FILTER with no output returns false (write-through)" , ( ) => {
447+ const filter = new Filter ( { name : "TargetOnly" } ) ;
448+ const f : FilterControlFunction = ( m ) => true ;
449+ const ctrl : FilterControlMessage = {
450+ type : FilterControlMessageType . SET_FILTER ,
451+ name : "Other" ,
452+ filter : f ,
453+ } ;
454+ expect ( filter . write ( ctrl ) ) . toBe ( false ) ;
455+ } ) ;
456+
457+ test ( "Non-targeted BYPASS/FILTER and unrelated control return false when no output" , ( ) => {
458+ const filter = new Filter ( { name : "TargetOnly" } ) ;
459+ const bypass : FilterControlMessage = {
460+ type : FilterControlMessageType . BYPASS ,
461+ name : "Other" ,
462+ } ;
463+ const filt : FilterControlMessage = {
464+ type : FilterControlMessageType . FILTER ,
465+ name : "Other" ,
466+ } ;
467+ expect ( filter . write ( bypass ) ) . toBe ( false ) ;
468+ expect ( filter . write ( filt ) ) . toBe ( false ) ;
469+ // default branch with unrelated control message and no output
470+ const unrelated : IPipeMessage = { type : QueueControlMessageType . FLUSH } ;
471+ expect ( filter . write ( unrelated ) ) . toBe ( false ) ;
472+ } ) ;
473+
436474 test ( "Filter function throws: write returns false and swallows error" , ( ) => {
437475 const received : IPipeMessage [ ] = [ ] ;
438476 const listener = new PipeListener ( ( m ) => received . push ( m ) ) ;
0 commit comments