@@ -15,21 +15,14 @@ import rule from "../../../lib/rules/infolabel-needs-labelling";
1515
1616ruleTester . run ( "infolabel-needs-labelling" , rule as unknown as Rule . RuleModule , {
1717 valid : [
18- // InfoLabel with aria-label
1918 `<InfoLabel aria-label="Additional information" />` ,
20- // InfoLabel with text content
2119 `<InfoLabel>Help text</InfoLabel>` ,
2220 `<InfoLabel>?</InfoLabel>` ,
2321 `<InfoLabel>ℹ️</InfoLabel>` ,
24- // InfoLabel with aria-labelledby that references existing element
2522 `<><Label id="info-label">Information</Label><InfoLabel aria-labelledby="info-label" /></>` ,
26- // InfoLabel wrapped in Tooltip
27- `<Tooltip content="Help information" relationship="label"><InfoLabel /></Tooltip>`
28- // TODO: Uncomment when hasLabeledChild is implemented
29- // InfoLabel with labeled child
30- // `<InfoLabel><img alt="Help icon" /></InfoLabel>`,
31- // InfoLabel with Icon child
32- // `<InfoLabel><InfoIcon /></InfoLabel>`
23+ `<Tooltip content="Help information" relationship="label"><InfoLabel /></Tooltip>` ,
24+ `<InfoLabel><img alt="Help icon" /></InfoLabel>` ,
25+ `<InfoLabel><InfoIcon /></InfoLabel>`
3326 ] ,
3427 invalid : [
3528 {
@@ -49,9 +42,16 @@ ruleTester.run("infolabel-needs-labelling", rule as unknown as Rule.RuleModule,
4942 errors : [ { messageId : "infoLabelNeedsLabelling" } ]
5043 } ,
5144 {
52- // aria-labelledby references ID that doesn't exist
5345 code : `<><Label id="wrong-id">Information</Label><InfoLabel aria-labelledby="info-label" /></>` ,
5446 errors : [ { messageId : "infoLabelNeedsLabelling" } ]
47+ } ,
48+ {
49+ code : `<InfoLabel><img /></InfoLabel>` ,
50+ errors : [ { messageId : "infoLabelNeedsLabelling" } ]
51+ } ,
52+ {
53+ code : `<InfoLabel><img alt="" /></InfoLabel>` ,
54+ errors : [ { messageId : "infoLabelNeedsLabelling" } ]
5555 }
5656 ]
5757} ) ;
0 commit comments