@@ -209,7 +209,7 @@ describe("hasAccessibleLabel (unit)", () => {
209209 expect ( hasAccessibleLabel ( node , element , mockContext , cfg ) ) . toBe ( true ) ;
210210 } ) ;
211211
212- test ( "true when allowDescribedByBy and hasAssociatedLabelViaAriaDescribedBy(...) === true" , ( ) => {
212+ test ( "true when allowDescribedBy and hasAssociatedLabelViaAriaDescribedBy(...) === true" , ( ) => {
213213 ( hasAssociatedLabelViaAriaDescribedby as jest . Mock ) . mockReturnValue ( true ) ;
214214 const node = makeOpeningElement ( "RadioGroup" ) ;
215215 const element = makeElement ( ) ;
@@ -229,6 +229,57 @@ describe("hasAccessibleLabel (unit)", () => {
229229 const element = makeElement ( ) ;
230230 expect ( hasAccessibleLabel ( node , element , mockContext , cfg ) ) . toBe ( true ) ;
231231 } ) ;
232+
233+ test ( "true when allowLabeledChild and hasLabeledChild(...) === true" , ( ) => {
234+ ( hasLabeledChild as jest . Mock ) . mockReturnValue ( true ) ;
235+ const node = makeOpeningElement ( "RadioGroup" ) ;
236+ const element = makeElement ( ) ;
237+ expect ( hasAccessibleLabel ( node , element , mockContext , cfg ) ) . toBe ( true ) ;
238+ } ) ;
239+
240+ test ( "true when allowLabeledChild and hasLabeledChild(...) === true" , ( ) => {
241+ ( hasLabeledChild as jest . Mock ) . mockReturnValue ( true ) ;
242+ const node = makeOpeningElement ( "RadioGroup" ) ;
243+ const element = makeElement ( ) ;
244+ expect ( hasAccessibleLabel ( node , element , mockContext , cfg ) ) . toBe ( true ) ;
245+ } ) ;
246+
247+ test ( "true when allowTextContentChild and hasTextContentChild(...) === true" , ( ) => {
248+ ( hasTextContentChild as jest . Mock ) . mockReturnValue ( true ) ;
249+ const node = makeOpeningElement ( "RadioGroup" ) ;
250+ const element = makeElement ( ) ;
251+ expect ( hasAccessibleLabel ( node , element , mockContext , cfg ) ) . toBe ( true ) ;
252+ } ) ;
253+
254+ describe ( "With all configs disabled" , ( ) => {
255+ const disabledCfg : LabeledControlConfig = {
256+ component : "RadioGroup" ,
257+ allowFieldParent : false ,
258+ allowHtmlFor : false ,
259+ allowLabelledBy : false ,
260+ allowWrappingLabel : false ,
261+ allowTooltipParent : false ,
262+ allowDescribedBy : false ,
263+ messageId : "noUnlabeledRadioGroup" ,
264+ description : "Accessibility: RadioGroup must have a programmatic and visual label." ,
265+ allowLabeledChild : false
266+ } ;
267+ test ( "returns false when all helpers return true but config is disabled" , ( ) => {
268+ ( hasDefinedProp as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
269+ ( hasNonEmptyProp as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
270+ ( hasAssociatedLabelViaAriaLabelledBy as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
271+ ( hasAssociatedLabelViaAriaDescribedby as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
272+ ( isInsideLabelTag as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
273+ ( hasAssociatedLabelViaHtmlFor as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
274+ ( hasFieldParent as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
275+ ( hasLabeledChild as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
276+ ( hasToolTipParent as jest . Mock ) . mockReset ( ) . mockReturnValue ( true ) ;
277+ const node = makeOpeningElement ( "RadioGroup" ) ;
278+ const element = makeElement ( ) ;
279+ const result = hasAccessibleLabel ( node , element , mockContext , disabledCfg ) ;
280+ expect ( result ) . toBe ( false ) ;
281+ } ) ;
282+ } ) ;
232283} ) ;
233284
234285/* -------------------------------------------------------------------------- */
0 commit comments