@@ -22,15 +22,14 @@ describe('Example', () => {
22
22
} ) ;
23
23
24
24
it ( 'should have title and hermes indicator on android' , async ( ) => {
25
- await expect ( element ( by . id ( 'appRootView' ) ) ) . toBeVisible ( ) ;
26
25
await expect ( element ( by . text ( 'Example DateTime Picker' ) ) ) . toBeVisible ( ) ;
27
26
if ( device . getPlatform ( ) === 'android' ) {
28
27
await expect ( element ( by . id ( 'hermesIndicator' ) ) ) . toExist ( ) ;
29
28
}
30
29
} ) ;
31
30
32
31
it ( 'should show date picker after tapping datePicker button' , async ( ) => {
33
- element ( by . id ( 'datePickerButton' ) ) . tap ( ) ;
32
+ await element ( by . id ( 'datePickerButton' ) ) . tap ( ) ;
34
33
35
34
if ( global . device . getPlatform ( ) === 'ios' ) {
36
35
await expect (
@@ -42,7 +41,7 @@ describe('Example', () => {
42
41
} ) ;
43
42
44
43
it ( 'Nothing should happen if date doesn`t change' , async ( ) => {
45
- element ( by . id ( 'datePickerButton' ) ) . tap ( ) ;
44
+ await element ( by . id ( 'datePickerButton' ) ) . tap ( ) ;
46
45
const dateTimeText = element ( by . id ( 'dateTimeText' ) ) ;
47
46
48
47
if ( global . device . getPlatform ( ) === 'ios' ) {
@@ -57,23 +56,23 @@ describe('Example', () => {
57
56
) ;
58
57
testElement . swipe ( 'left' , 'fast' , '100' ) ;
59
58
testElement . tapAtPoint ( { x : 50 , y : 200 } ) ;
60
- element ( by . text ( 'CANCEL' ) ) . tap ( ) ;
59
+ await element ( by . text ( 'CANCEL' ) ) . tap ( ) ;
61
60
}
62
61
63
62
await expect ( dateTimeText ) . toHaveText ( '08/21/2020' ) ;
64
63
} ) ;
65
64
66
65
it ( 'should update dateTimeText when date changes' , async ( ) => {
67
- element ( by . id ( 'datePickerButton' ) ) . tap ( ) ;
66
+ await element ( by . id ( 'datePickerButton' ) ) . tap ( ) ;
68
67
const dateTimeText = element ( by . id ( 'dateTimeText' ) ) ;
69
68
70
69
if ( global . device . getPlatform ( ) === 'ios' ) {
71
70
const testElement = element (
72
71
by . type ( 'UIPickerView' ) . withAncestor ( by . id ( 'dateTimePicker' ) ) ,
73
72
) ;
74
- testElement . setColumnToValue ( 0 , 'November' ) ;
75
- testElement . setColumnToValue ( 1 , '3' ) ;
76
- testElement . setColumnToValue ( 2 , '1800' ) ;
73
+ await testElement . setColumnToValue ( 0 , 'November' ) ;
74
+ await testElement . setColumnToValue ( 1 , '3' ) ;
75
+ await testElement . setColumnToValue ( 2 , '1800' ) ;
77
76
78
77
await expect ( dateTimeText ) . toHaveText ( '11/03/1800' ) ;
79
78
} else {
@@ -82,16 +81,16 @@ describe('Example', () => {
82
81
. type ( 'android.widget.ScrollView' )
83
82
. withAncestor ( by . type ( 'android.widget.DatePicker' ) ) ,
84
83
) ;
85
- testElement . swipe ( 'left' , 'fast' , '100' ) ;
86
- testElement . tapAtPoint ( { x : 50 , y : 200 } ) ;
87
- element ( by . text ( 'OK' ) ) . tap ( ) ;
84
+ await testElement . swipe ( 'left' , 'fast' , '100' ) ;
85
+ await testElement . tapAtPoint ( { x : 50 , y : 200 } ) ;
86
+ await element ( by . text ( 'OK' ) ) . tap ( ) ;
88
87
89
88
await expect ( dateTimeText ) . toHaveText ( '09/13/2020' ) ;
90
89
}
91
90
} ) ;
92
91
93
92
it ( 'should show time picker after tapping timePicker button' , async ( ) => {
94
- element ( by . id ( 'timePickerButton' ) ) . tap ( ) ;
93
+ await element ( by . id ( 'timePickerButton' ) ) . tap ( ) ;
95
94
96
95
if ( global . device . getPlatform ( ) === 'ios' ) {
97
96
await expect (
@@ -103,7 +102,7 @@ describe('Example', () => {
103
102
} ) ;
104
103
105
104
it ( 'Nothing should happen if time doesn`t change' , async ( ) => {
106
- element ( by . id ( 'timePickerButton' ) ) . tap ( ) ;
105
+ await element ( by . id ( 'timePickerButton' ) ) . tap ( ) ;
107
106
const dateTimeText = element ( by . id ( 'dateTimeText' ) ) ;
108
107
109
108
if ( global . device . getPlatform ( ) === 'ios' ) {
@@ -119,16 +118,16 @@ describe('Example', () => {
119
118
} ) ;
120
119
121
120
it ( 'should change time text when time changes' , async ( ) => {
122
- element ( by . id ( 'timePickerButton' ) ) . tap ( ) ;
121
+ await element ( by . id ( 'timePickerButton' ) ) . tap ( ) ;
123
122
const dateTimeText = element ( by . id ( 'dateTimeText' ) ) ;
124
123
125
124
if ( global . device . getPlatform ( ) === 'ios' ) {
126
125
const testElement = element (
127
126
by . type ( 'UIPickerView' ) . withAncestor ( by . id ( 'dateTimePicker' ) ) ,
128
127
) ;
129
- testElement . setColumnToValue ( 0 , '2' ) ;
130
- testElement . setColumnToValue ( 1 , '44' ) ;
131
- testElement . setColumnToValue ( 2 , 'PM' ) ;
128
+ await testElement . setColumnToValue ( 0 , '2' ) ;
129
+ await testElement . setColumnToValue ( 1 , '44' ) ;
130
+ await testElement . setColumnToValue ( 2 , 'PM' ) ;
132
131
133
132
await expect ( dateTimeText ) . toHaveText ( '14:44' ) ;
134
133
} else {
@@ -139,105 +138,82 @@ describe('Example', () => {
139
138
}
140
139
} ) ;
141
140
142
- it ( "shouldn't change time text when time changes to less than half of minuteInterval" , async ( ) => {
143
- element ( by . id ( 'timePickerIntervalButton ' ) ) . tap ( ) ;
141
+ it ( 'should correct time text when using minuteInterval' , async ( ) => {
142
+ await element ( by . id ( 'timePickerDefaultIntervalButton ' ) ) . tap ( ) ;
144
143
const dateTimeText = element ( by . id ( 'dateTimeText' ) ) ;
145
144
146
145
if ( global . device . getPlatform ( ) === 'ios' ) {
147
146
const testElement = element (
148
147
by . type ( 'UIPickerView' ) . withAncestor ( by . id ( 'dateTimePicker' ) ) ,
149
148
) ;
150
- testElement . setColumnToValue ( 0 , '2' ) ;
151
- testElement . setColumnToValue ( 1 , '42' ) ;
152
- testElement . setColumnToValue ( 2 , 'PM' ) ;
153
-
154
- await expect ( dateTimeText ) . toHaveText ( '14:40' ) ;
155
- } else {
156
- const keyboardButton = element (
157
- by . type ( 'androidx.appcompat.widget.AppCompatImageButton' ) ,
158
- ) ;
159
- keyboardButton . tap ( ) ;
160
- const testElement = element (
161
- by
162
- . type ( 'androidx.appcompat.widget.AppCompatEditText' )
163
- . and ( by . text ( '15' ) ) ,
164
- ) ;
165
- testElement . tap ( ) ;
166
- testElement . replaceText ( '17' ) ;
167
- element ( by . text ( 'OK' ) ) . tap ( ) ;
168
-
169
- await expect ( dateTimeText ) . toHaveText ( '23:15' ) ;
170
- }
171
- } ) ;
172
-
173
- it ( 'should change time text when time changes to more than half of minuteInterval' , async ( ) => {
174
- element ( by . id ( 'timePickerIntervalButton' ) ) . tap ( ) ;
175
- const dateTimeText = element ( by . id ( 'dateTimeText' ) ) ;
176
-
177
- if ( global . device . getPlatform ( ) === 'ios' ) {
178
- const testElement = element (
179
- by . type ( 'UIPickerView' ) . withAncestor ( by . id ( 'dateTimePicker' ) ) ,
180
- ) ;
181
- testElement . setColumnToValue ( 0 , '2' ) ;
182
- testElement . setColumnToValue ( 1 , '44' ) ;
183
- testElement . setColumnToValue ( 2 , 'PM' ) ;
149
+ await testElement . setColumnToValue ( 0 , '2' ) ;
150
+ await testElement . setColumnToValue ( 1 , '45' ) ;
151
+ await testElement . setColumnToValue ( 2 , 'PM' ) ;
184
152
185
153
await expect ( dateTimeText ) . toHaveText ( '14:45' ) ;
186
154
} else {
187
155
const keyboardButton = element (
188
156
by . type ( 'androidx.appcompat.widget.AppCompatImageButton' ) ,
189
157
) ;
190
- keyboardButton . tap ( ) ;
158
+ await keyboardButton . tap ( ) ;
191
159
const testElement = element (
192
160
by
193
161
. type ( 'androidx.appcompat.widget.AppCompatEditText' )
194
162
. and ( by . text ( '15' ) ) ,
195
163
) ;
196
- testElement . tap ( ) ;
197
- testElement . replaceText ( '18' ) ;
198
- element ( by . text ( 'OK' ) ) . tap ( ) ;
164
+ await testElement . tap ( ) ;
165
+ await testElement . replaceText ( '18' ) ;
166
+ await element ( by . text ( 'OK' ) ) . tap ( ) ;
199
167
200
168
await expect ( dateTimeText ) . toHaveText ( '23:20' ) ;
201
169
}
202
170
} ) ;
203
171
204
- it ( 'should correct input on the fly on android ' , async ( ) => {
205
- element ( by . id ( 'timePickerIntervalButton ' ) ) . tap ( ) ;
172
+ it ( 'should change minutes when pressing in default interval button ' , async ( ) => {
173
+ await element ( by . id ( 'timePickerDefaultIntervalButton ' ) ) . tap ( ) ;
206
174
const dateTimeText = element ( by . id ( 'dateTimeText' ) ) ;
207
175
208
- if ( global . device . getPlatform ( ) !== 'ios ') {
176
+ if ( global . device . getPlatform ( ) === 'android ') {
209
177
const keyboardButton = element (
210
178
by . type ( 'androidx.appcompat.widget.AppCompatImageButton' ) ,
211
179
) ;
212
- keyboardButton . tap ( ) ;
180
+ await keyboardButton . tap ( ) ;
213
181
214
- element (
182
+ await element (
215
183
by
216
184
. type ( 'androidx.appcompat.widget.AppCompatEditText' )
217
185
. and ( by . text ( '15' ) ) ,
218
186
) . tap ( ) ;
219
- element (
187
+
188
+ await element (
220
189
by
221
190
. type ( 'androidx.appcompat.widget.AppCompatEditText' )
222
191
. and ( by . text ( '15' ) ) ,
223
192
) . tapBackspaceKey ( ) ;
193
+
224
194
element (
225
195
by
226
196
. type ( 'androidx.appcompat.widget.AppCompatEditText' )
227
197
. and ( by . text ( '1' ) ) ,
228
- ) . typeText ( '8' ) ;
198
+ ) ;
199
+
200
+ const minuteTextinput = element (
201
+ by . type ( 'androidx.appcompat.widget.AppCompatEditText' ) ,
202
+ ) . atIndex ( 1 ) ;
203
+
204
+ await minuteTextinput . replaceText ( '55' ) ;
229
205
230
206
await expect (
231
207
element (
232
208
by
233
209
. type ( 'androidx.appcompat.widget.AppCompatEditText' )
234
- . and ( by . text ( '18 ' ) ) ,
210
+ . and ( by . text ( '55 ' ) ) ,
235
211
) ,
236
- ) . toExist ( ) ;
212
+ ) . toBeVisible ( ) ;
237
213
238
- element ( by . text ( 'OK' ) ) . tap ( ) ;
214
+ await element ( by . text ( 'OK' ) ) . tap ( ) ;
239
215
240
- await expect ( dateTimeText ) . toHaveText ( '23:20 ' ) ;
216
+ await expect ( dateTimeText ) . toHaveText ( '23:55 ' ) ;
241
217
}
242
218
} ) ;
243
219
} ) ;
0 commit comments