-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathform-control-has-label.test.ts
98 lines (97 loc) · 2.91 KB
/
form-control-has-label.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import rule from "../form-control-has-label";
import makeRuleTester from "./makeRuleTester";
makeRuleTester("form-control-has-label", rule, {
valid: [
"<label for=''><input type='text' /></label>",
"<input type='text' aria-label='test' />",
"<label for=''>text</label><input type='text' />",
"<input type='button'>",
`
<label>
<div>
<input type="radio" />
</div>
<div>
<slot />
</div>
</label>
`,
`
<div aria-hidden="true">
<input value="1" type="text" />
</div>
`,
{
code: "<custom-label for='input'>text</custom-label><input type='text' id='input' />",
options: [{ labelComponents: ["CustomLabel"] }]
},
{
code: "<custom-label label='text'><input type='text' id='input' /></custom-label>",
options: [{
labelComponentsWithRequiredAttributes: [
{ name: "CustomLabel", requiredAttributes: ["label"] },
],
}]
},
{
code: `
<custom-label label='text'><input type='text' id='input' /></custom-label>
<custom-label-other><input type='text' id='input' /></custom-label-other>
`,
options: [{
labelComponents: [
"CustomLabelOther",
],
labelComponentsWithRequiredAttributes: [
{ name: "CustomLabel", requiredAttributes: ["label"] },
],
}]
},
{
code: "<custom-label label='text' id='id' for='bla'><input type='text' id='input' /></custom-label>",
options: [{
labelComponentsWithRequiredAttributes: [
{ name: "CustomLabel", requiredAttributes: ["label", "id", "for"] },
],
}]
},
{
code: "<custom-label><input type='text' id='input' /></custom-label>",
options: [{ labelComponents: ["CustomLabel"] }]
},
"<b-form-input />"
],
invalid: [
"<input type='text' />",
"<textarea type='text'></textarea>",
"<custom-label for='input'>text</custom-label><input type='text' id='input' />",
{
code: "<custom-label><input type='text' id='input' /></custom-label>",
options: [{
labelComponentsWithRequiredAttributes: [
{ name: "CustomLabel", requiredAttributes: ["label"] },
],
}],
errors: [{ messageId: "default" }]
},
{
code: "<div><b-form-input /></div>",
options: [{ controlComponents: ["b-form-input"] }],
errors: [{ messageId: "default" }]
},
{
code: "<div label='text'><b-form-input /></div>",
options: [{ controlComponents: ["b-form-input"] }],
errors: [{ messageId: "default" }]
},
{
code: "<custom-label label='text'>label next to input</custom-label><input type='text' id='input' />",
options: [{
labelComponentsWithRequiredAttributes: [
{ name: "CustomLabel", requiredAttributes: ["label"] },
],
}],
errors: [{ messageId: "default" }]
},
]
});