Skip to content

Commit 1eb5d03

Browse files
committed
fixed broken test
1 parent 3ad2214 commit 1eb5d03

File tree

2 files changed

+42
-42
lines changed

2 files changed

+42
-42
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
// const linkBasedComponents = ["Link", "a"]; // , "BreadcrumbButton"
5-
const linkBasedComponents = ["Link"];
4+
const linkBasedComponents = ["Link", "a"]; // , "BreadcrumbButton"
5+
66
module.exports = {
77
linkBasedComponents
88
};

tests/lib/rules/link-missing-labelling.test.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,44 @@ function generateTestCases(componentName: string, imageName: string) {
1414
return {
1515
valid: [
1616
// Valid cases
17-
// `<${componentName} href="https://www.bing.com">This is a link</${componentName}>`,
18-
// `<${componentName} href="https://www.bing.com">This is a link<${imageName} src="img_girl.jpg" alt="" /></${componentName}>`,
19-
// `<${componentName} href="https://www.bing.com">This is a link<${imageName} src="img_girl.jpg" alt="" aria-hidden="true" /></${componentName}>`,
20-
// `<${componentName} href="https://www.bing.com"><${imageName} src="img_girl.jpg" alt="The girl with the dog." /></${componentName}>`,
21-
`<${componentName} href="https://www.bing.com"><${imageName} src="img_girl.jpg" aria-label="The girl with the dog." /></${componentName}>`
22-
// `<${componentName} href="https://www.bing.com" aria-label="The girl with the dog."><${imageName} src="img_girl.jpg" /></${componentName}>`
23-
// `<${componentName} href="https://www.bing.com" title="The girl with the dog."><${imageName} src="img_girl.jpg" /></${componentName}>`,
24-
// `<><Label id="my-label-2">This is a Header</Label><${componentName} href="https://www.bing.com" aria-labelledby="my-label-2"><${imageName} src="img_girl.jpg" /></${componentName}></>`,
25-
// `<${componentName} href="https://www.bing.com"><${imageName} src="img1.jpg" /><${imageName} src="img2.jpg" alt="The girl with the dog." /></${componentName}>`
17+
`<${componentName} href="https://www.bing.com">This is a link</${componentName}>`,
18+
`<${componentName} href="https://www.bing.com">This is a link<${imageName} src="img_girl.jpg" alt="" /></${componentName}>`,
19+
`<${componentName} href="https://www.bing.com">This is a link<${imageName} src="img_girl.jpg" alt="" aria-hidden="true" /></${componentName}>`,
20+
`<${componentName} href="https://www.bing.com"><${imageName} src="img_girl.jpg" alt="The girl with the dog." /></${componentName}>`,
21+
`<${componentName} href="https://www.bing.com"><${imageName} src="img_girl.jpg" aria-label="The girl with the dog." /></${componentName}>`,
22+
`<${componentName} href="https://www.bing.com" aria-label="The girl with the dog."><${imageName} src="img_girl.jpg" /></${componentName}>`,
23+
`<${componentName} href="https://www.bing.com" title="The girl with the dog."><${imageName} src="img_girl.jpg" /></${componentName}>`,
24+
`<><Label id="my-label-2">This is a Header</Label><${componentName} href="https://www.bing.com" aria-labelledby="my-label-2"><${imageName} src="img_girl.jpg" /></${componentName}></>`,
25+
`<${componentName} href="https://www.bing.com"><${imageName} src="img1.jpg" /><${imageName} src="img2.jpg" alt="The girl with the dog." /></${componentName}>`
2626
],
27-
invalid: []
28-
// invalid: [
29-
// // Invalid cases
30-
// {
31-
// code: `<${componentName} />`,
32-
// errors: [{ messageId: "missingHref" }, { messageId: "missingAriaLabel" }]
33-
// },
34-
// {
35-
// code: `<${componentName}><${imageName} src="img_girl.jpg" alt="The girl with the dog." /></${componentName}>`,
36-
// errors: [{ messageId: "missingHref" }]
37-
// },
38-
// {
39-
// code: `<${componentName} href="https://www.bing.com"><${imageName} src="img_girl.jpg" /></${componentName}>`,
40-
// errors: [{ messageId: "missingAriaLabel" }]
41-
// },
42-
// {
43-
// code: `<${componentName}><${imageName} src="img_girl.jpg" /></${componentName}>`,
44-
// errors: [{ messageId: "missingHref" }, { messageId: "missingAriaLabel" }]
45-
// },
46-
// {
47-
// code: `<${componentName} href="https://www.bing.com"><${imageName} src="img_girl.jpg" alt="" aria-hidden="true" /></${componentName}>`,
48-
// errors: [{ messageId: "missingAriaLabel" }]
49-
// },
50-
// {
51-
// code: `<${componentName} href="https://www.bing.com"><${imageName} src="img1.jpg" /><${imageName} src="img2.jpg" /></${componentName}>`,
52-
// errors: [{ messageId: "missingAriaLabel" }]
53-
// }
54-
// ]
27+
28+
invalid: [
29+
// Invalid cases
30+
{
31+
code: `<${componentName} />`,
32+
errors: [{ messageId: "missingHref" }, { messageId: "missingAriaLabel" }]
33+
},
34+
{
35+
code: `<${componentName}><${imageName} src="img_girl.jpg" alt="The girl with the dog." /></${componentName}>`,
36+
errors: [{ messageId: "missingHref" }]
37+
},
38+
{
39+
code: `<${componentName} href="https://www.bing.com"><${imageName} src="img_girl.jpg" /></${componentName}>`,
40+
errors: [{ messageId: "missingAriaLabel" }]
41+
},
42+
{
43+
code: `<${componentName}><${imageName} src="img_girl.jpg" /></${componentName}>`,
44+
errors: [{ messageId: "missingHref" }, { messageId: "missingAriaLabel" }]
45+
},
46+
{
47+
code: `<${componentName} href="https://www.bing.com"><${imageName} src="img_girl.jpg" alt="" aria-hidden="true" /></${componentName}>`,
48+
errors: [{ messageId: "missingAriaLabel" }]
49+
},
50+
{
51+
code: `<${componentName} href="https://www.bing.com"><${imageName} src="img1.jpg" /><${imageName} src="img2.jpg" /></${componentName}>`,
52+
errors: [{ messageId: "missingAriaLabel" }]
53+
}
54+
]
5555
};
5656
}
5757

@@ -69,9 +69,9 @@ function generateAllTestCases() {
6969
});
7070

7171
// Also generate test cases for each native DOM image node (e.g., img, svg)
72-
// imageDomNodes.forEach(imageComponent => {
73-
// testSets.push(generateTestCases(linkComponent, imageComponent));
74-
// });
72+
imageDomNodes.forEach(imageComponent => {
73+
testSets.push(generateTestCases(linkComponent, imageComponent));
74+
});
7575
});
7676

7777
return testSets;

0 commit comments

Comments
 (0)