@@ -15,7 +15,7 @@ describe('combobox-nav', function() {
1515 <input type="text">
1616 <ul role="listbox" id="list-id">
1717 <li id="baymax" role="option">Baymax</li>
18- <li><del>BB-8</del></li>
18+ <li id="bb-8" ><del>BB-8</del></li>
1919 <li id="hubot" role="option">Hubot</li>
2020 <li id="r2-d2" role="option">R2-D2</li>
2121 </ul>
@@ -71,12 +71,12 @@ describe('combobox-nav', function() {
7171 <li id="r2-d2" role="option">R2-D2</li>
7272 <li id="johnny-5" hidden role="option">Johnny 5</li>
7373 <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>
7575 </ul>
7676 `
7777 input = document . querySelector ( 'input' )
7878 list = document . querySelector ( 'ul' )
79- options = document . querySelectorAll ( 'li ' )
79+ options = document . querySelectorAll ( '[role=option] ' )
8080 combobox = new Combobox ( input , list )
8181 combobox . start ( )
8282 } )
@@ -99,27 +99,27 @@ describe('combobox-nav', function() {
9999 assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'baymax' )
100100
101101 press ( input , 'ArrowDown' )
102- assert . equal ( options [ 2 ] . getAttribute ( 'aria-selected' ) , 'true' )
102+ assert . equal ( options [ 1 ] . getAttribute ( 'aria-selected' ) , 'true' )
103103 assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'hubot' )
104104
105105 press ( input , 'Enter' )
106106
107107 press ( input , 'ArrowDown' )
108- assert . equal ( options [ 3 ] . getAttribute ( 'aria-selected' ) , 'true' )
108+ assert . equal ( options [ 2 ] . getAttribute ( 'aria-selected' ) , 'true' )
109109 assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'r2-d2' )
110110
111111 press ( input , 'ArrowDown' )
112- assert . equal ( options [ 5 ] . getAttribute ( 'aria-selected' ) , 'true' )
112+ assert . equal ( options [ 4 ] . getAttribute ( 'aria-selected' ) , 'true' )
113113 assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'wall-e' )
114114 press ( input , 'Enter' )
115- click ( options [ 5 ] )
115+ click ( document . getElementById ( 'wall-e' ) )
116116
117117 press ( input , 'ArrowUp' )
118- assert . equal ( options [ 3 ] . getAttribute ( 'aria-selected' ) , 'true' )
118+ assert . equal ( options [ 2 ] . getAttribute ( 'aria-selected' ) , 'true' )
119119 assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'r2-d2' )
120120
121121 press ( input , 'ArrowUp' )
122- assert . equal ( options [ 2 ] . getAttribute ( 'aria-selected' ) , 'true' )
122+ assert . equal ( options [ 1 ] . getAttribute ( 'aria-selected' ) , 'true' )
123123 assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'hubot' )
124124
125125 press ( input , 'Enter' )
@@ -135,9 +135,9 @@ describe('combobox-nav', function() {
135135 expectedTargets . push ( target . id )
136136 } )
137137
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' ) )
141141
142142 assert . equal ( expectedTargets . length , 2 )
143143 assert . equal ( expectedTargets [ 0 ] , 'hubot' )
@@ -170,7 +170,7 @@ describe('combobox-nav', function() {
170170
171171 click ( document . querySelectorAll ( '[role=option]' ) [ 5 ] )
172172 assert ( eventFired )
173- assert . equal ( window . location . hash , '#wall-e ' )
173+ assert . equal ( window . location . hash , '#link ' )
174174 } )
175175
176176 it ( 'clears aria-activedescendant and sets aria-selected=false when cleared' , function ( ) {
@@ -197,7 +197,7 @@ describe('combobox-nav', function() {
197197
198198 press ( input , 'ArrowDown' )
199199
200- assert . equal ( options [ 2 ] . getAttribute ( 'aria-selected' ) , 'true' )
200+ assert . equal ( options [ 1 ] . getAttribute ( 'aria-selected' ) , 'true' )
201201 assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'hubot' )
202202 assert . equal ( list . scrollTop , 36 )
203203 } )
0 commit comments