@@ -10,10 +10,11 @@ function click(element) {
10
10
element . dispatchEvent ( new MouseEvent ( 'click' , { bubbles : true , cancelable : true } ) )
11
11
}
12
12
13
- describe ( 'combobox-nav' , function ( ) {
14
- describe ( 'with API' , function ( ) {
15
- let input , list
16
- beforeEach ( function ( ) {
13
+ describe ( 'combobox-nav' , function ( ) {
14
+ describe ( 'with API' , function ( ) {
15
+ let input
16
+ let list
17
+ beforeEach ( function ( ) {
17
18
document . body . innerHTML = `
18
19
<input type="text">
19
20
<ul role="listbox" id="list-id">
@@ -27,11 +28,11 @@ describe('combobox-nav', function() {
27
28
list = document . querySelector ( 'ul' )
28
29
} )
29
30
30
- afterEach ( function ( ) {
31
+ afterEach ( function ( ) {
31
32
document . body . innerHTML = ''
32
33
} )
33
34
34
- it ( 'installs, starts, navigates, stops, and uninstalls' , function ( ) {
35
+ it ( 'installs, starts, navigates, stops, and uninstalls' , function ( ) {
35
36
const combobox = new Combobox ( input , list )
36
37
assert . equal ( input . getAttribute ( 'role' ) , 'combobox' )
37
38
assert . equal ( input . getAttribute ( 'aria-expanded' ) , 'false' )
@@ -63,9 +64,12 @@ describe('combobox-nav', function() {
63
64
} )
64
65
} )
65
66
66
- describe ( 'with default setup' , function ( ) {
67
- let input , list , options , combobox
68
- beforeEach ( function ( ) {
67
+ describe ( 'with default setup' , function ( ) {
68
+ let input
69
+ let list
70
+ let options
71
+ let combobox
72
+ beforeEach ( function ( ) {
69
73
document . body . innerHTML = `
70
74
<input type="text">
71
75
<ul role="listbox" id="list-id">
@@ -85,16 +89,16 @@ describe('combobox-nav', function() {
85
89
combobox . start ( )
86
90
} )
87
91
88
- afterEach ( function ( ) {
92
+ afterEach ( function ( ) {
89
93
combobox . destroy ( )
90
94
combobox = null
91
95
document . body . innerHTML = ''
92
96
} )
93
97
94
- it ( 'updates attributes on keyboard events' , function ( ) {
98
+ it ( 'updates attributes on keyboard events' , function ( ) {
95
99
const expectedTargets = [ ]
96
100
97
- document . addEventListener ( 'combobox-commit' , function ( { target} ) {
101
+ document . addEventListener ( 'combobox-commit' , function ( { target} ) {
98
102
expectedTargets . push ( target . id )
99
103
} )
100
104
@@ -144,10 +148,10 @@ describe('combobox-nav', function() {
144
148
assert . equal ( expectedTargets [ 1 ] , 'link' )
145
149
} )
146
150
147
- it ( 'fires commit events on click' , function ( ) {
151
+ it ( 'fires commit events on click' , function ( ) {
148
152
const expectedTargets = [ ]
149
153
150
- document . addEventListener ( 'combobox-commit' , function ( { target} ) {
154
+ document . addEventListener ( 'combobox-commit' , function ( { target} ) {
151
155
expectedTargets . push ( target . id )
152
156
} )
153
157
@@ -160,7 +164,7 @@ describe('combobox-nav', function() {
160
164
assert . equal ( expectedTargets [ 1 ] , 'baymax' )
161
165
} )
162
166
163
- it ( 'clear selection on input operation' , function ( ) {
167
+ it ( 'clear selection on input operation' , function ( ) {
164
168
press ( input , 'ArrowDown' )
165
169
assert . equal ( options [ 0 ] . getAttribute ( 'aria-selected' ) , 'true' )
166
170
assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'baymax' )
@@ -182,9 +186,9 @@ describe('combobox-nav', function() {
182
186
assert ( ! input . hasAttribute ( 'aria-activedescendant' ) , 'Nothing should be selected' )
183
187
} )
184
188
185
- it ( 'fires event and follows the link on click' , function ( ) {
189
+ it ( 'fires event and follows the link on click' , function ( ) {
186
190
let eventFired = false
187
- document . addEventListener ( 'combobox-commit' , function ( ) {
191
+ document . addEventListener ( 'combobox-commit' , function ( ) {
188
192
eventFired = true
189
193
} )
190
194
@@ -193,7 +197,7 @@ describe('combobox-nav', function() {
193
197
assert . equal ( window . location . hash , '#link' )
194
198
} )
195
199
196
- it ( 'clears aria-activedescendant and sets aria-selected=false when cleared' , function ( ) {
200
+ it ( 'clears aria-activedescendant and sets aria-selected=false when cleared' , function ( ) {
197
201
press ( input , 'ArrowDown' )
198
202
assert . equal ( options [ 0 ] . getAttribute ( 'aria-selected' ) , 'true' )
199
203
assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'baymax' )
@@ -204,7 +208,7 @@ describe('combobox-nav', function() {
204
208
assert . equal ( input . hasAttribute ( 'aria-activedescendant' ) , false )
205
209
} )
206
210
207
- it ( 'scrolls when the selected item is not in view' , function ( ) {
211
+ it ( 'scrolls when the selected item is not in view' , function ( ) {
208
212
list . style . overflow = 'auto'
209
213
list . style . height = '18px'
210
214
list . style . position = 'relative'
0 commit comments