@@ -124,6 +124,53 @@ const customTemplatesExample = () => {
124
124
} )
125
125
}
126
126
127
+ const autoselectExample = ( ) => {
128
+ describe ( 'autoselect example' , function ( ) {
129
+ this . retries ( 3 )
130
+
131
+ const input = 'input#autocomplete-autoselect'
132
+ const menu = `${ input } + ul`
133
+ const wrapper = '#tt-autoselect'
134
+ const hint = `${ wrapper } .autocomplete__hint`
135
+
136
+ beforeEach ( ( ) => {
137
+ browser . setValue ( input , '' ) // Prevent autofilling, IE likes to do this.
138
+ } )
139
+
140
+ it ( 'should display hint' , ( ) => {
141
+ browser . click ( input )
142
+ browser . setValue ( input , 'ita' )
143
+ browser . waitForVisible ( menu )
144
+ expect ( browser . isVisible ( menu ) ) . to . equal ( true )
145
+ expect ( browser . isVisible ( hint ) ) . to . equal ( true )
146
+ expect ( browser . getValue ( hint ) ) . to . equal ( 'italy' )
147
+ } )
148
+ } )
149
+ }
150
+
151
+ const doNotDisplayHintExample = ( ) => {
152
+ describe ( 'doNotDisplayHintExample example' , function ( ) {
153
+ this . retries ( 3 )
154
+
155
+ const input = 'input#autocomplete-autoselect'
156
+ const menu = `${ input } + ul`
157
+ const wrapper = '#tt-tt-noHint'
158
+ const hint = `${ wrapper } .autocomplete__hint`
159
+
160
+ beforeEach ( ( ) => {
161
+ browser . setValue ( input , '' ) // Prevent autofilling, IE likes to do this.
162
+ } )
163
+
164
+ it ( 'should not display hint' , ( ) => {
165
+ browser . click ( input )
166
+ browser . setValue ( input , 'ita' )
167
+ browser . waitForVisible ( menu )
168
+ expect ( browser . isVisible ( menu ) ) . to . equal ( true )
169
+ expect ( browser . isVisible ( hint ) ) . to . equal ( false )
170
+ } )
171
+ } )
172
+ }
173
+
127
174
const takeScreenshotsIfFail = ( ) => {
128
175
afterEach ( function ( ) {
129
176
const testFailed = this . currentTest . state === 'failed'
@@ -149,6 +196,8 @@ describe('Accessible Autocomplete', () => {
149
196
150
197
basicExample ( )
151
198
customTemplatesExample ( )
199
+ autoselectExample ( )
200
+ doNotDisplayHintExample ( )
152
201
153
202
takeScreenshotsIfFail ( )
154
203
} )
0 commit comments