@@ -186,7 +186,7 @@ describe('UuiInput in Form', () => {
186
186
} ) ;
187
187
} ) ;
188
188
189
- describe ( 'custom error' , ( ) => {
189
+ describe ( 'custom error though attributes ' , ( ) => {
190
190
beforeEach ( async ( ) => {
191
191
element . setAttribute ( 'error' , 'true' ) ;
192
192
await elementUpdated ( element ) ;
@@ -212,6 +212,32 @@ describe('UuiInput in Form', () => {
212
212
expect ( formElement . checkValidity ( ) ) . to . be . true ;
213
213
} ) ;
214
214
} ) ;
215
+
216
+ describe ( 'custom error through setCustomValidity' , ( ) => {
217
+ it ( 'sets element to invalid when it sets custom validity' , async ( ) => {
218
+ const validationMessage = 'custom error' ;
219
+ element . setCustomValidity ( validationMessage ) ;
220
+ expect ( element . checkValidity ( ) ) . to . be . false ;
221
+ expect ( element . validationMessage ) . to . equal ( validationMessage ) ;
222
+ } ) ;
223
+
224
+ it ( 'sets the form to invalid when value is empty' , async ( ) => {
225
+ element . setCustomValidity ( 'custom error' ) ;
226
+ expect ( formElement . checkValidity ( ) ) . to . be . false ;
227
+ } ) ;
228
+
229
+ it ( 'sets element to valid when it sets custom validity to an empty string' , async ( ) => {
230
+ const validationMessage = '' ;
231
+ element . setCustomValidity ( validationMessage ) ;
232
+ expect ( element . checkValidity ( ) ) . to . be . true ;
233
+ expect ( element . validationMessage ) . to . equal ( validationMessage ) ;
234
+ } ) ;
235
+
236
+ it ( 'sets the form to valid when it doesnt have custom validity' , async ( ) => {
237
+ element . setCustomValidity ( '' ) ;
238
+ expect ( formElement . checkValidity ( ) ) . to . be . true ;
239
+ } ) ;
240
+ } ) ;
215
241
} ) ;
216
242
217
243
describe ( 'native validation' , ( ) => {
0 commit comments