Skip to content

Commit 2762304

Browse files
authored
test: make sure no initial validation happens for time-picker (#4160)
1 parent 32b587f commit 2762304

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

‎packages/time-picker/test/form-input.test.js‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from '@esm-bundle/chai';
2-
import { fixtureSync, focusout } from '@vaadin/testing-helpers';
2+
import { fixtureSync, focusout, nextRender } from '@vaadin/testing-helpers';
33
import sinon from 'sinon';
44
import { TimePicker } from '../src/vaadin-time-picker.js';
55

@@ -19,6 +19,40 @@ describe('form input', () => {
1919
inputElement.dispatchEvent(new CustomEvent('input', { bubbles: true, composed: true }));
2020
}
2121

22+
describe('initial validation', () => {
23+
let validateSpy;
24+
25+
beforeEach(() => {
26+
timePicker = document.createElement('vaadin-time-picker');
27+
validateSpy = sinon.spy(timePicker, 'validate');
28+
});
29+
30+
afterEach(() => {
31+
timePicker.remove();
32+
});
33+
34+
it('should not validate by default', async () => {
35+
document.body.appendChild(timePicker);
36+
await nextRender();
37+
expect(validateSpy.called).to.be.false;
38+
});
39+
40+
it('should not validate when the field has an initial value', async () => {
41+
timePicker.value = '12:00';
42+
document.body.appendChild(timePicker);
43+
await nextRender();
44+
expect(validateSpy.called).to.be.false;
45+
});
46+
47+
it('should not validate when the field has an initial value and invalid', async () => {
48+
timePicker.value = '12:00';
49+
timePicker.invalid = true;
50+
document.body.appendChild(timePicker);
51+
await nextRender();
52+
expect(validateSpy.called).to.be.false;
53+
});
54+
});
55+
2256
describe('default validator', () => {
2357
beforeEach(() => {
2458
timePicker = fixtureSync(`<vaadin-time-picker></vaadin-time-picker>`);

0 commit comments

Comments
 (0)