This commit is contained in:
Cory LaViska
2022-07-27 16:45:39 -04:00
parent 47388d4a3f
commit 1a7fbbfab4
3 changed files with 36 additions and 3 deletions

View File

@@ -188,4 +188,25 @@ describe('<sl-input>', () => {
expect(form.reportValidity()).to.be.false;
});
});
describe('when type="number"', () => {
it('should be valid when the value is within the boundary of a step', async () => {
const el = await fixture<SlInput>(html` <sl-input type="number" step=".5" value="1.5"></sl-input> `);
expect(el.invalid).to.be.false;
});
it('should be invalid when the value is not within the boundary of a step', async () => {
const el = await fixture<SlInput>(html` <sl-input type="number" step=".5" value="1.25"></sl-input> `);
expect(el.invalid).to.be.true;
});
it('should update validity when step changes', async () => {
const el = await fixture<SlInput>(html` <sl-input type="number" step=".5" value="1.5"></sl-input> `);
expect(el.invalid).to.be.false;
el.step = 1;
await el.updateComplete;
expect(el.invalid).to.be.true;
});
});
});