|
1 | 1 | import { expect } from '@esm-bundle/chai'; |
2 | | -import { aTimeout, fixtureSync, focusin, focusout } from '@vaadin/testing-helpers'; |
| 2 | +import { fixtureSync, focusin, focusout } from '@vaadin/testing-helpers'; |
3 | 3 | import sinon from 'sinon'; |
4 | 4 | import '../src/vaadin-custom-field.js'; |
5 | 5 | import { dispatchChange } from './common.js'; |
@@ -69,33 +69,7 @@ describe('custom field', () => { |
69 | 69 | }); |
70 | 70 | }); |
71 | 71 |
|
72 | | - describe('label', () => { |
73 | | - let labelElement; |
74 | | - |
75 | | - beforeEach(() => { |
76 | | - labelElement = customField.querySelector('[slot="label"]'); |
77 | | - }); |
78 | | - |
79 | | - it('should be undefined by default', () => { |
80 | | - expect(customField.label).to.be.undefined; |
81 | | - }); |
82 | | - |
83 | | - it('should be displayed when assigned', () => { |
84 | | - customField.label = 'Foo'; |
85 | | - expect(labelElement.textContent).to.equal('Foo'); |
86 | | - }); |
87 | | - |
88 | | - it('should set has-label attribute on host element when displayed', () => { |
89 | | - customField.label = 'Foo'; |
90 | | - expect(customField.hasAttribute('has-label')).to.be.true; |
91 | | - }); |
92 | | - }); |
93 | | - |
94 | 72 | describe('aria-required', () => { |
95 | | - it('should not have aria-required attribute by default', () => { |
96 | | - expect(customField.hasAttribute('aria-required')).to.be.false; |
97 | | - }); |
98 | | - |
99 | 73 | it('should toggle aria-required attribute on required property change', () => { |
100 | 74 | customField.required = true; |
101 | 75 | expect(customField.getAttribute('aria-required')).to.equal('true'); |
@@ -123,35 +97,6 @@ describe('custom field', () => { |
123 | 97 | }); |
124 | 98 | }); |
125 | 99 |
|
126 | | - describe('errorMessage', () => { |
127 | | - let error; |
128 | | - |
129 | | - beforeEach(() => { |
130 | | - customField.invalid = true; |
131 | | - error = customField.querySelector('[slot="error-message"]'); |
132 | | - }); |
133 | | - |
134 | | - it('should set error message text content when errorMessage is provided', () => { |
135 | | - customField.errorMessage = 'foo'; |
136 | | - expect(error.textContent).to.equal('foo'); |
137 | | - }); |
138 | | - |
139 | | - it('should set has-error-message attribute when errorMessage is provided', () => { |
140 | | - customField.errorMessage = 'foo'; |
141 | | - expect(customField.hasAttribute('has-error-message')).to.be.true; |
142 | | - }); |
143 | | - |
144 | | - it('should not set has-error-message when errorMessage is set to empty string', () => { |
145 | | - customField.errorMessage = ''; |
146 | | - expect(customField.hasAttribute('has-error-message')).to.be.false; |
147 | | - }); |
148 | | - |
149 | | - it('should not set has-error-message when errorMessage is set to null', () => { |
150 | | - customField.errorMessage = null; |
151 | | - expect(customField.hasAttribute('has-error-message')).to.be.false; |
152 | | - }); |
153 | | - }); |
154 | | - |
155 | 100 | describe('required', () => { |
156 | 101 | beforeEach(() => { |
157 | 102 | customField.required = true; |
@@ -181,40 +126,6 @@ describe('custom field', () => { |
181 | 126 | }); |
182 | 127 | }); |
183 | 128 |
|
184 | | - describe('ARIA', () => { |
185 | | - let label, helper, error; |
186 | | - |
187 | | - beforeEach(() => { |
188 | | - customField.helperText = 'Helper'; |
189 | | - label = customField.querySelector('[slot="label"]'); |
190 | | - helper = customField.querySelector('[slot="helper"]'); |
191 | | - error = customField.querySelector('[slot="error-message"]'); |
192 | | - customField.label = 'label'; |
193 | | - customField.helperText = 'helper'; |
194 | | - customField.errorMessage = 'error'; |
195 | | - }); |
196 | | - |
197 | | - it('should set correct role attribute on the custom field', () => { |
198 | | - expect(customField.getAttribute('role')).to.equal('group'); |
199 | | - }); |
200 | | - |
201 | | - it('should add label and helper text to aria-labelledby when valid', () => { |
202 | | - const aria = customField.getAttribute('aria-labelledby'); |
203 | | - expect(aria).to.include(helper.id); |
204 | | - expect(aria).to.not.include(error.id); |
205 | | - expect(aria).to.include(label.id); |
206 | | - }); |
207 | | - |
208 | | - it('should add error message to aria-labelledby when field is invalid', async () => { |
209 | | - customField.invalid = true; |
210 | | - await aTimeout(0); |
211 | | - const aria = customField.getAttribute('aria-labelledby'); |
212 | | - expect(aria).to.include(helper.id); |
213 | | - expect(aria).to.include(error.id); |
214 | | - expect(aria).to.include(label.id); |
215 | | - }); |
216 | | - }); |
217 | | - |
218 | 129 | describe('validation', () => { |
219 | 130 | it('should check validity on validate', () => { |
220 | 131 | const spy = sinon.spy(customField, 'checkValidity'); |
|
0 commit comments