@@ -17,7 +17,22 @@ import { labelBasedComponents, elementsUsedAsLabels } from "../../../lib/applica
1717function generateTestCases ( labelComponent : string , componentName : string ) {
1818 return {
1919 valid : [
20- `<><${ labelComponent } id="test-span">Some Label</${ labelComponent } ><${ componentName } id="some-id" aria-labelledby="test-span"/></>`
20+ `<><${ labelComponent } id="test-span">Some Label</${ labelComponent } ><${ componentName } id="some-id" aria-labelledby="test-span"/></>` ,
21+ // expression forms: binary concatenation and template literal (cover expression-literal forms)
22+ "<><" +
23+ labelComponent +
24+ ' id={"my-label" + 1}>Some Label</' +
25+ labelComponent +
26+ "><" +
27+ componentName +
28+ ' aria-labelledby={"my-label" + 1}/></>' ,
29+ "<><" +
30+ labelComponent +
31+ " id={`my-label-${value}`}>Some Label</" +
32+ labelComponent +
33+ "><" +
34+ componentName +
35+ " aria-labelledby={`my-label-${value}`}/></>"
2136 ] ,
2237 invalid : [
2338 {
@@ -38,7 +53,22 @@ function generateTestCasesLabel(labelComponent: string, componentName: string) {
3853 `<${ labelComponent } >test<SomeNesting><${ componentName } /></SomeNesting></${ labelComponent } >` ,
3954 `<Field label="this is my label"><${ componentName } /></Field>` ,
4055 `<${ componentName } aria-label="this is my component" />` ,
41- `<><${ labelComponent } id="paragraph_label-2">type here</${ labelComponent } ><${ componentName } aria-labelledby="paragraph_label-2"></${ componentName } ><${ labelComponent } id="paragraph_label-3">type here</${ labelComponent } ><${ componentName } aria-labelledby="paragraph_label-3"></${ componentName } ></>`
56+ `<><${ labelComponent } id="paragraph_label-2">type here</${ labelComponent } ><${ componentName } aria-labelledby="paragraph_label-2"></${ componentName } ><${ labelComponent } id="paragraph_label-3">type here</${ labelComponent } ><${ componentName } aria-labelledby="paragraph_label-3"></${ componentName } ></>` ,
57+ // expression forms for htmlFor/id pairing
58+ "<><" +
59+ labelComponent +
60+ ' htmlFor={"my-input" + 1}>Some Label</' +
61+ labelComponent +
62+ "><" +
63+ componentName +
64+ ' id={"my-input" + 1}/></>' ,
65+ "<><" +
66+ labelComponent +
67+ " htmlFor={`my-input-${value}`}>Some Label</" +
68+ labelComponent +
69+ "><" +
70+ componentName +
71+ " id={`my-input-${value}`}/></>"
4272 ] ,
4373 invalid : [
4474 {
0 commit comments