Skip to content

Commit 24accec

Browse files
committed
test(vue): add tests for input-otp
1 parent 8c29200 commit 24accec

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

packages/vue/test/base/src/views/Inputs.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
<ion-input v-model="input" label="Input"></ion-input>
4242
</ion-item>
4343

44+
<ion-item>
45+
<ion-input-otp :value="inputOtp" @ion-input="e => inputOtp = e.detail.value"></ion-input-otp>
46+
</ion-item>
47+
4448
<ion-item>
4549
<ion-range label="Range" :dual-knobs="true" :min="0" :max="100" slot="end" v-model="range"></ion-range>
4650
</ion-item>
@@ -77,6 +81,7 @@
7781
Checkbox: {{ checkbox }}<br>
7882
Toggle: {{ toggle }}<br>
7983
Input: <span id="input-ref">{{ input }}</span><br>
84+
Input OTP: <span id="input-otp-ref">{{ inputOtp }}</span><br>
8085
Range: {{ range }}<br>
8186
Textarea: <span id="textarea-ref">{{ textarea }}</span><br>
8287
Searchbar: <span id="searchbar-ref">{{ searchbar }}</span><br>
@@ -104,6 +109,7 @@ import {
104109
IonDatetime,
105110
IonHeader,
106111
IonInput,
112+
IonInputOtp,
107113
IonItem,
108114
IonLabel,
109115
IonPage,
@@ -132,6 +138,7 @@ export default defineComponent({
132138
IonDatetime,
133139
IonHeader,
134140
IonInput,
141+
IonInputOtp,
135142
IonItem,
136143
IonLabel,
137144
IonPage,
@@ -152,6 +159,7 @@ export default defineComponent({
152159
const checkbox = ref(false);
153160
const toggle = ref(false);
154161
const input = ref('');
162+
const inputOtp = ref('');
155163
const range = ref({
156164
lower: 30,
157165
upper: 70
@@ -167,6 +175,7 @@ export default defineComponent({
167175
checkbox.value = false;
168176
toggle.value = false;
169177
input.value = '';
178+
inputOtp.value = '';
170179
range.value = {
171180
lower: 30,
172181
upper: 70
@@ -183,6 +192,7 @@ export default defineComponent({
183192
checkbox.value = true;
184193
toggle.value = true;
185194
input.value = 'Hello World';
195+
inputOtp.value = '1234';
186196
range.value = {
187197
lower: 10,
188198
upper: 90
@@ -199,6 +209,7 @@ export default defineComponent({
199209
checkbox,
200210
toggle,
201211
input,
212+
inputOtp,
202213
range,
203214
textarea,
204215
searchbar,

packages/vue/test/base/tests/e2e/specs/inputs.cy.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ describe('Inputs', () => {
66
cy.get('ion-checkbox').should('have.prop', 'checked').and('eq', false);
77
cy.get('ion-toggle').should('have.prop', 'checked').and('eq', false);
88
cy.get('ion-input').should('have.prop', 'value').and('eq', '');
9+
cy.get('ion-input-otp').should('have.prop', 'value').and('eq', '');
910
cy.get('ion-range').should('have.prop', 'value').and('deep.eq', { lower: 30, upper: 70 });
1011
cy.get('ion-textarea').should('have.prop', 'value').and('eq', '');
1112
cy.get('ion-searchbar').should('have.prop', 'value').and('eq', '');
@@ -21,6 +22,7 @@ describe('Inputs', () => {
2122
cy.get('ion-checkbox').should('have.prop', 'checked').and('eq', true);
2223
cy.get('ion-toggle').should('have.prop', 'checked').and('eq', true);
2324
cy.get('ion-input').should('have.prop', 'value').and('eq', 'Hello World');
25+
cy.get('ion-input-otp').should('have.prop', 'value').and('eq', '1234');
2426
cy.get('ion-range').should('have.prop', 'value').and('deep.eq', { lower: 10, upper: 90 });
2527
cy.get('ion-textarea').should('have.prop', 'value').and('eq', 'Lorem Ipsum');
2628
cy.get('ion-searchbar').should('have.prop', 'value').and('eq', 'Search Query');
@@ -34,6 +36,7 @@ describe('Inputs', () => {
3436
cy.get('ion-checkbox').should('have.prop', 'checked').and('eq', false);
3537
cy.get('ion-toggle').should('have.prop', 'checked').and('eq', false);
3638
cy.get('ion-input').should('have.prop', 'value').and('eq', '');
39+
cy.get('ion-input-otp').should('have.prop', 'value').and('eq', '');
3740
cy.get('ion-range').should('have.prop', 'value').and('deep.eq', { lower: 30, upper: 70 });
3841
cy.get('ion-textarea').should('have.prop', 'value').and('eq', '');
3942
cy.get('ion-searchbar').should('have.prop', 'value').and('eq', '');
@@ -49,6 +52,11 @@ describe('Inputs', () => {
4952

5053
cy.get('#input-ref').should('have.text', 'Hello Input');
5154
});
55+
it('typing into input-otp should update ref', () => {
56+
cy.get('ion-input-otp input').eq(0).type('1234', { scrollBehavior: false });
57+
58+
cy.get('#input-otp-ref').should('have.text', '1234');
59+
});
5260
it('typing into searchbar should update ref', () => {
5361
cy.get('ion-searchbar input').type('Hello Searchbar', { scrollBehavior: false });
5462

0 commit comments

Comments
 (0)