@@ -15,7 +15,7 @@ describe('combobox-nav', function() {
15
15
<input type="text">
16
16
<ul role="listbox" id="list-id">
17
17
<li id="baymax" role="option">Baymax</li>
18
- <li><del>BB-8</del></li>
18
+ <li id="bb-8" ><del>BB-8</del></li>
19
19
<li id="hubot" role="option">Hubot</li>
20
20
<li id="r2-d2" role="option">R2-D2</li>
21
21
</ul>
@@ -71,12 +71,12 @@ describe('combobox-nav', function() {
71
71
<li id="r2-d2" role="option">R2-D2</li>
72
72
<li id="johnny-5" hidden role="option">Johnny 5</li>
73
73
<li id="wall-e" role="option" aria-disabled="true">Wall-E</li>
74
- <li><a href="#wall-e " role="option">Wall-E </a></li>
74
+ <li><a href="#link " role="option" id="link">Link </a></li>
75
75
</ul>
76
76
`
77
77
input = document . querySelector ( 'input' )
78
78
list = document . querySelector ( 'ul' )
79
- options = document . querySelectorAll ( 'li ' )
79
+ options = document . querySelectorAll ( '[role=option] ' )
80
80
combobox = new Combobox ( input , list )
81
81
combobox . start ( )
82
82
} )
@@ -99,27 +99,27 @@ describe('combobox-nav', function() {
99
99
assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'baymax' )
100
100
101
101
press ( input , 'ArrowDown' )
102
- assert . equal ( options [ 2 ] . getAttribute ( 'aria-selected' ) , 'true' )
102
+ assert . equal ( options [ 1 ] . getAttribute ( 'aria-selected' ) , 'true' )
103
103
assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'hubot' )
104
104
105
105
press ( input , 'Enter' )
106
106
107
107
press ( input , 'ArrowDown' )
108
- assert . equal ( options [ 3 ] . getAttribute ( 'aria-selected' ) , 'true' )
108
+ assert . equal ( options [ 2 ] . getAttribute ( 'aria-selected' ) , 'true' )
109
109
assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'r2-d2' )
110
110
111
111
press ( input , 'ArrowDown' )
112
- assert . equal ( options [ 5 ] . getAttribute ( 'aria-selected' ) , 'true' )
112
+ assert . equal ( options [ 4 ] . getAttribute ( 'aria-selected' ) , 'true' )
113
113
assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'wall-e' )
114
114
press ( input , 'Enter' )
115
- click ( options [ 5 ] )
115
+ click ( document . getElementById ( 'wall-e' ) )
116
116
117
117
press ( input , 'ArrowUp' )
118
- assert . equal ( options [ 3 ] . getAttribute ( 'aria-selected' ) , 'true' )
118
+ assert . equal ( options [ 2 ] . getAttribute ( 'aria-selected' ) , 'true' )
119
119
assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'r2-d2' )
120
120
121
121
press ( input , 'ArrowUp' )
122
- assert . equal ( options [ 2 ] . getAttribute ( 'aria-selected' ) , 'true' )
122
+ assert . equal ( options [ 1 ] . getAttribute ( 'aria-selected' ) , 'true' )
123
123
assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'hubot' )
124
124
125
125
press ( input , 'Enter' )
@@ -135,9 +135,9 @@ describe('combobox-nav', function() {
135
135
expectedTargets . push ( target . id )
136
136
} )
137
137
138
- click ( options [ 2 ] )
139
- click ( options [ 1 ] )
140
- click ( options [ 0 ] )
138
+ click ( document . getElementById ( 'hubot' ) )
139
+ click ( document . querySelectorAll ( 'li' ) [ 1 ] )
140
+ click ( document . getElementById ( 'baymax' ) )
141
141
142
142
assert . equal ( expectedTargets . length , 2 )
143
143
assert . equal ( expectedTargets [ 0 ] , 'hubot' )
@@ -170,7 +170,7 @@ describe('combobox-nav', function() {
170
170
171
171
click ( document . querySelectorAll ( '[role=option]' ) [ 5 ] )
172
172
assert ( eventFired )
173
- assert . equal ( window . location . hash , '#wall-e ' )
173
+ assert . equal ( window . location . hash , '#link ' )
174
174
} )
175
175
176
176
it ( 'clears aria-activedescendant and sets aria-selected=false when cleared' , function ( ) {
@@ -197,7 +197,7 @@ describe('combobox-nav', function() {
197
197
198
198
press ( input , 'ArrowDown' )
199
199
200
- assert . equal ( options [ 2 ] . getAttribute ( 'aria-selected' ) , 'true' )
200
+ assert . equal ( options [ 1 ] . getAttribute ( 'aria-selected' ) , 'true' )
201
201
assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'hubot' )
202
202
assert . equal ( list . scrollTop , 36 )
203
203
} )
0 commit comments