Skip to content

Commit f717293

Browse files
authored
test: add snapshot tests for checkbox-group (#3518)
1 parent 4746f91 commit f717293

3 files changed

Lines changed: 189 additions & 8 deletions

File tree

‎packages/checkbox-group/test/checkbox-group.test.js‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ describe('vaadin-checkbox-group', () => {
3737
await nextFrame();
3838
});
3939

40-
it('should set role attribute to group', () => {
41-
expect(group.getAttribute('role')).to.equal('group');
42-
});
43-
4440
it('should keep initial disabled property for checkboxes', () => {
4541
expect(checkboxes[0].disabled).to.be.false;
4642
expect(checkboxes[1].disabled).to.be.true;
@@ -69,10 +65,6 @@ describe('vaadin-checkbox-group', () => {
6965
checkboxes = [...group.querySelectorAll('vaadin-checkbox')];
7066
});
7167

72-
it('should set aria-disabled to true when disabled', () => {
73-
expect(group.getAttribute('aria-disabled')).to.eq('true');
74-
});
75-
7668
it('should propagate disabled property to checkboxes', () => {
7769
checkboxes.forEach((checkbox) => {
7870
expect(checkbox.disabled).to.be.true;
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
/* @web/test-runner snapshot v1 */
2+
export const snapshots = {};
3+
4+
snapshots["vaadin-checkbox-group host default"] =
5+
`<vaadin-checkbox-group role="group">
6+
<vaadin-checkbox
7+
has-label=""
8+
has-value=""
9+
label="Checkbox 1"
10+
value="1"
11+
>
12+
<label
13+
for="vaadin-checkbox-0"
14+
id="label-vaadin-checkbox-1"
15+
slot="label"
16+
>
17+
Checkbox 1
18+
</label>
19+
<input
20+
id="vaadin-checkbox-0"
21+
slot="input"
22+
type="checkbox"
23+
value="1"
24+
>
25+
</vaadin-checkbox>
26+
<vaadin-checkbox
27+
has-label=""
28+
has-value=""
29+
label="Checkbox 2"
30+
value="2"
31+
>
32+
<label
33+
for="vaadin-checkbox-1"
34+
id="label-vaadin-checkbox-2"
35+
slot="label"
36+
>
37+
Checkbox 2
38+
</label>
39+
<input
40+
id="vaadin-checkbox-1"
41+
slot="input"
42+
type="checkbox"
43+
value="2"
44+
>
45+
</vaadin-checkbox>
46+
<label
47+
id="label-vaadin-checkbox-group-0"
48+
slot="label"
49+
>
50+
</label>
51+
<div
52+
hidden=""
53+
id="error-message-vaadin-checkbox-group-0"
54+
slot="error-message"
55+
>
56+
</div>
57+
</vaadin-checkbox-group>
58+
`;
59+
/* end snapshot vaadin-checkbox-group host default */
60+
61+
snapshots["vaadin-checkbox-group host disabled"] =
62+
`<vaadin-checkbox-group
63+
aria-disabled="true"
64+
disabled=""
65+
role="group"
66+
>
67+
<vaadin-checkbox
68+
aria-disabled="true"
69+
disabled=""
70+
has-label=""
71+
has-value=""
72+
label="Checkbox 1"
73+
value="1"
74+
>
75+
<label
76+
for="vaadin-checkbox-2"
77+
id="label-vaadin-checkbox-4"
78+
slot="label"
79+
>
80+
Checkbox 1
81+
</label>
82+
<input
83+
disabled=""
84+
id="vaadin-checkbox-2"
85+
slot="input"
86+
tabindex="-1"
87+
type="checkbox"
88+
value="1"
89+
>
90+
</vaadin-checkbox>
91+
<vaadin-checkbox
92+
aria-disabled="true"
93+
disabled=""
94+
has-label=""
95+
has-value=""
96+
label="Checkbox 2"
97+
value="2"
98+
>
99+
<label
100+
for="vaadin-checkbox-3"
101+
id="label-vaadin-checkbox-5"
102+
slot="label"
103+
>
104+
Checkbox 2
105+
</label>
106+
<input
107+
disabled=""
108+
id="vaadin-checkbox-3"
109+
slot="input"
110+
tabindex="-1"
111+
type="checkbox"
112+
value="2"
113+
>
114+
</vaadin-checkbox>
115+
<label
116+
id="label-vaadin-checkbox-group-3"
117+
slot="label"
118+
>
119+
</label>
120+
<div
121+
hidden=""
122+
id="error-message-vaadin-checkbox-group-1"
123+
slot="error-message"
124+
>
125+
</div>
126+
</vaadin-checkbox-group>
127+
`;
128+
/* end snapshot vaadin-checkbox-group host disabled */
129+
130+
snapshots["vaadin-checkbox-group shadow default"] =
131+
`<div class="vaadin-group-field-container">
132+
<div part="label">
133+
<slot name="label">
134+
</slot>
135+
<span
136+
aria-hidden="true"
137+
part="required-indicator"
138+
>
139+
</span>
140+
</div>
141+
<div part="group-field">
142+
<slot>
143+
</slot>
144+
</div>
145+
<div part="helper-text">
146+
<slot name="helper">
147+
</slot>
148+
</div>
149+
<div part="error-message">
150+
<slot name="error-message">
151+
</slot>
152+
</div>
153+
</div>
154+
`;
155+
/* end snapshot vaadin-checkbox-group shadow default */
156+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { expect } from '@esm-bundle/chai';
2+
import { fixtureSync } from '@vaadin/testing-helpers';
3+
import '../../vaadin-checkbox-group.js';
4+
5+
describe('vaadin-checkbox-group', () => {
6+
let group;
7+
8+
beforeEach(() => {
9+
group = fixtureSync(`
10+
<vaadin-checkbox-group>
11+
<vaadin-checkbox value="1" label="Checkbox 1"></vaadin-checkbox>
12+
<vaadin-checkbox value="2" label="Checkbox 2"></vaadin-checkbox>
13+
</vaadin-checkbox-group>
14+
`);
15+
});
16+
17+
describe('host', () => {
18+
it('default', async () => {
19+
await expect(group).dom.to.equalSnapshot();
20+
});
21+
22+
it('disabled', async () => {
23+
group.disabled = true;
24+
await expect(group).dom.to.equalSnapshot();
25+
});
26+
});
27+
28+
describe('shadow', () => {
29+
it('default', async () => {
30+
await expect(group).shadowDom.to.equalSnapshot();
31+
});
32+
});
33+
});

0 commit comments

Comments
 (0)