-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(VNumberInput): avoid native number input weird behaviours (#19605)
fixes #19438 fixes #19558 fixes #19538 fixes #19494 Co-authored-by: John Leider <john@vuetifyjs.com>
- Loading branch information
1 parent
f4a5414
commit 42e482f
Showing
2 changed files
with
139 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/vuetify/src/labs/VNumberInput/__tests__/VNumberInput.spec.cy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/// <reference types="../../../../types/cypress" /> | ||
|
||
// Components | ||
import { VNumberInput } from '../VNumberInput' | ||
|
||
// Utilities | ||
import { ref } from 'vue' | ||
|
||
describe('VNumberInput', () => { | ||
describe('native number input quirks', () => { | ||
it('should not bypass min', () => { | ||
const numberInputValue = ref(1) | ||
cy.mount(() => | ||
<VNumberInput min={ 5 } max={ 15 } v-model={ numberInputValue.value } ></VNumberInput> | ||
) | ||
.get('.v-number-input input').should('have.value', '5') | ||
.should(() => expect(numberInputValue.value).to.equal(5)) | ||
}) | ||
|
||
it('should not bypass max', () => { | ||
const numberInputValue = ref(20) | ||
cy.mount(() => | ||
<VNumberInput min={ 5 } max={ 15 } v-model={ numberInputValue.value } ></VNumberInput> | ||
) | ||
.get('.v-number-input input').should('have.value', '15') | ||
.should(() => expect(numberInputValue.value).to.equal(15)) | ||
}) | ||
|
||
it('should support decimal step', () => { | ||
const numberInputValue = ref(0) | ||
cy.mount(() => | ||
( | ||
<VNumberInput | ||
step={ 0.03 } | ||
v-model={ numberInputValue.value } | ||
></VNumberInput> | ||
) | ||
) | ||
.get('button[name="increment-btn"]') | ||
.click() | ||
.get('.v-number-input input').should('have.value', '0.03') | ||
.then(() => expect(numberInputValue.value).to.equal(0.03)) | ||
.get('button[name="increment-btn"]') | ||
.click() | ||
.get('.v-number-input input').should('have.value', '0.06') | ||
.then(() => expect(numberInputValue.value).to.equal(0.06)) | ||
.get('button[name="decrement-btn"]') | ||
.click() | ||
.get('.v-number-input input').should('have.value', '0.03') | ||
.then(() => expect(numberInputValue.value).to.equal(0.03)) | ||
.get('button[name="decrement-btn"]') | ||
.click() | ||
.get('.v-number-input input').should('have.value', '0') | ||
.then(() => expect(numberInputValue.value).to.equal(0)) | ||
}) | ||
}) | ||
}) |