-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc23d1f
commit 0a55521
Showing
3 changed files
with
95 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
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
62 changes: 62 additions & 0 deletions
62
packages/vuetify/src/labs/VOtpInput/__tests__/VOtpInput.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,62 @@ | ||
/// <reference types="../../../../types/cypress" /> | ||
|
||
// Components | ||
import { VOtpInput } from '../VOtpInput' | ||
|
||
// Utilities | ||
import { keyValues } from '@/util' | ||
|
||
describe('VOtpInput', () => { | ||
it('enters value and moves to next input and blurs at end', () => { | ||
cy.mount(() => (<VOtpInput />)) | ||
.get('.v-otp-input input').eq(0) | ||
.type('1') | ||
.get('.v-otp-input input').eq(1) | ||
.should('be.focused') | ||
.type('2') | ||
.get('.v-otp-input input').eq(2) | ||
.should('be.focused') | ||
.type('3') | ||
.get('.v-otp-input input').eq(3) | ||
.should('be.focused') | ||
.type('4') | ||
.get('.v-otp-input input').eq(4) | ||
.should('be.focused') | ||
.type('5') | ||
.get('.v-otp-input input').eq(5) | ||
.should('be.focused') | ||
.type('6') | ||
.should('not.be.focused') | ||
}) | ||
|
||
it('removes value and stays on current input when using delete', () => { | ||
cy.mount(() => (<VOtpInput />)) | ||
.get('.v-otp-input input').eq(0) | ||
.type('1234') | ||
.get('.v-otp-input input').eq(4) | ||
.should('be.focused') | ||
.trigger('keydown', { key: keyValues.left }) | ||
.trigger('keydown', { key: keyValues.left }) | ||
.get('.v-otp-input input').eq(2) | ||
.should('be.focused') | ||
.should('have.value', '3') | ||
.trigger('keydown', { key: keyValues.delete }) | ||
.should('have.value', '4') | ||
}) | ||
|
||
it('removes value and goes back when using backspace', () => { | ||
cy.mount(() => (<VOtpInput />)) | ||
.get('.v-otp-input input').eq(0) | ||
.type('1234') | ||
.get('.v-otp-input input').eq(4) | ||
.should('be.focused') | ||
.trigger('keydown', { key: keyValues.backspace }) | ||
.get('.v-otp-input input').eq(3) | ||
.should('be.focused') | ||
.should('have.value', 4) | ||
.trigger('keydown', { key: keyValues.backspace }) | ||
.get('.v-otp-input input').eq(2) | ||
.should('be.focused') | ||
.should('have.value', 3) | ||
}) | ||
}) |