@@ -489,4 +489,108 @@ describe('ContentFeature class', () => {
489489 expect ( object . someProp . toString . toString . toString ( ) ) . not . toBe ( fn . toString . toString . toString ( ) ) ;
490490 } ) ;
491491 } ) ;
492+
493+ describe ( 'injectName condition' , ( ) => {
494+ it ( 'should match when injectName condition is met' , ( ) => {
495+ class MyTestFeature extends ContentFeature {
496+ /** @returns {'apple-isolated' } */
497+ get injectName ( ) {
498+ return 'apple-isolated' ;
499+ }
500+
501+ testMatchInjectNameConditional ( conditionBlock ) {
502+ return this . _matchInjectNameConditional ( conditionBlock ) ;
503+ }
504+ }
505+
506+ const args = {
507+ site : {
508+ domain : 'example.com' ,
509+ url : 'http://example.com' ,
510+ } ,
511+ } ;
512+
513+ const feature = new MyTestFeature ( 'test' , { } , args ) ;
514+ const result = feature . testMatchInjectNameConditional ( {
515+ injectName : 'apple-isolated' ,
516+ } ) ;
517+ expect ( result ) . toBe ( true ) ;
518+ } ) ;
519+
520+ it ( 'should not match when injectName condition is not met' , ( ) => {
521+ class MyTestFeature extends ContentFeature {
522+ /** @returns {'apple-isolated' } */
523+ get injectName ( ) {
524+ return 'apple-isolated' ;
525+ }
526+
527+ testMatchInjectNameConditional ( conditionBlock ) {
528+ return this . _matchInjectNameConditional ( conditionBlock ) ;
529+ }
530+ }
531+
532+ const args = {
533+ site : {
534+ domain : 'example.com' ,
535+ url : 'http://example.com' ,
536+ } ,
537+ } ;
538+
539+ const feature = new MyTestFeature ( 'test' , { } , args ) ;
540+ const result = feature . testMatchInjectNameConditional ( {
541+ injectName : 'firefox' ,
542+ } ) ;
543+ expect ( result ) . toBe ( false ) ;
544+ } ) ;
545+
546+ it ( 'should handle undefined injectName gracefully' , ( ) => {
547+ class MyTestFeature extends ContentFeature {
548+ /** @returns {undefined } */
549+ get injectName ( ) {
550+ return undefined ;
551+ }
552+
553+ testMatchInjectNameConditional ( conditionBlock ) {
554+ return this . _matchInjectNameConditional ( conditionBlock ) ;
555+ }
556+ }
557+
558+ const args = {
559+ site : {
560+ domain : 'example.com' ,
561+ url : 'http://example.com' ,
562+ } ,
563+ } ;
564+
565+ const feature = new MyTestFeature ( 'test' , { } , args ) ;
566+ const result = feature . testMatchInjectNameConditional ( {
567+ injectName : 'apple-isolated' ,
568+ } ) ;
569+ expect ( result ) . toBe ( false ) ;
570+ } ) ;
571+
572+ it ( 'should handle missing injectName condition' , ( ) => {
573+ class MyTestFeature extends ContentFeature {
574+ /** @returns {'apple-isolated' } */
575+ get injectName ( ) {
576+ return 'apple-isolated' ;
577+ }
578+
579+ testMatchInjectNameConditional ( conditionBlock ) {
580+ return this . _matchInjectNameConditional ( conditionBlock ) ;
581+ }
582+ }
583+
584+ const args = {
585+ site : {
586+ domain : 'example.com' ,
587+ url : 'http://example.com' ,
588+ } ,
589+ } ;
590+
591+ const feature = new MyTestFeature ( 'test' , { } , args ) ;
592+ const result = feature . testMatchInjectNameConditional ( { } ) ;
593+ expect ( result ) . toBe ( false ) ;
594+ } ) ;
595+ } ) ;
492596} ) ;
0 commit comments