@@ -89,7 +89,7 @@ describe("hasAccessibleLabel (unit)", () => {
8989 allowDescribedBy : true ,
9090 messageId : "errorMsg" ,
9191 description : "anything" ,
92- allowLabeledChild : false
92+ allowLabeledChild : true
9393 } ;
9494
9595 test ( "returns false when no heuristics pass" , ( ) => {
@@ -150,11 +150,46 @@ describe("hasAccessibleLabel (unit)", () => {
150150 expect ( hasAccessibleLabel ( node , { } , cfg ) ) . toBe ( true ) ;
151151 } ) ;
152152
153- test ( "true when allowDescribedByBy and hasAssociatedLabelViaAriaDescribedBy(...) === true" , ( ) => {
153+ test ( "true when allowDescribedBy and hasAssociatedLabelViaAriaDescribedBy(...) === true" , ( ) => {
154154 ( hasAssociatedLabelViaAriaDescribedby as jest . Mock ) . mockReturnValue ( true ) ;
155155 const node = makeOpeningElement ( "RadioGroup" ) ;
156156 expect ( hasAccessibleLabel ( node , { } , cfg ) ) . toBe ( true ) ;
157157 } ) ;
158+
159+ test ( "true when allowLabeledChild and hasLabeledChild(...) === true" , ( ) => {
160+ ( hasLabeledChild as jest . Mock ) . mockReturnValue ( true ) ;
161+ const node = makeOpeningElement ( "RadioGroup" ) ;
162+ expect ( hasAccessibleLabel ( node , { } , cfg ) ) . toBe ( true ) ;
163+ } ) ;
164+
165+ describe ( "With all configs disabled" , ( ) => {
166+ const disabledCfg : LabeledControlConfig = {
167+ component : "RadioGroup" ,
168+ allowFieldParent : false ,
169+ allowHtmlFor : false ,
170+ allowLabelledBy : false ,
171+ allowWrappingLabel : false ,
172+ allowTooltipParent : false ,
173+ allowDescribedBy : false ,
174+ messageId : "noUnlabeledRadioGroup" ,
175+ description : "Accessibility: RadioGroup must have a programmatic and visual label." ,
176+ allowLabeledChild : false
177+ } ;
178+ test ( "returns false when all helpers return true but config is disabled" , ( ) => {
179+ ( hasDefinedProp as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
180+ ( hasNonEmptyProp as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
181+ ( hasAssociatedLabelViaAriaLabelledBy as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
182+ ( hasAssociatedLabelViaAriaDescribedby as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
183+ ( isInsideLabelTag as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
184+ ( hasAssociatedLabelViaHtmlFor as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
185+ ( hasFieldParent as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
186+ ( hasLabeledChild as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
187+ ( hasToolTipParent as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
188+ const node = makeOpeningElement ( "RadioGroup" ) ;
189+ const result = hasAccessibleLabel ( node , { } , disabledCfg ) ;
190+ expect ( result ) . toBe ( false ) ;
191+ } ) ;
192+ } ) ;
158193} ) ;
159194
160195/* -------------------------------------------------------------------------- */
@@ -176,7 +211,7 @@ describe("makeLabeledControlRule (RuleTester integration)", () => {
176211 allowDescribedBy : true ,
177212 messageId : "noUnlabeledRadioGroup" ,
178213 description : "Accessibility: RadioGroup must have a programmatic and visual label." ,
179- allowLabeledChild : false
214+ allowLabeledChild : true
180215 } ;
181216
182217 // 1) No heuristics -> report
0 commit comments