11import Combobox from '../dist/index.js'
2+
3+ const ctrlBindings = ! ! navigator . userAgent . match ( / M a c i n t o s h / )
4+
25function press ( input , key , ctrlKey ) {
36 input . dispatchEvent ( new KeyboardEvent ( 'keydown' , { key, ctrlKey} ) )
47}
@@ -105,17 +108,17 @@ describe('combobox-nav', function() {
105108
106109 press ( input , 'Enter' )
107110
108- press ( input , 'ArrowDown' )
111+ ctrlBindings ? press ( input , 'n' , true ) : press ( input , 'ArrowDown' )
109112 assert . equal ( options [ 2 ] . getAttribute ( 'aria-selected' ) , 'true' )
110113 assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'r2-d2' )
111114
112- press ( input , 'ArrowDown' )
115+ ctrlBindings ? press ( input , 'n' , true ) : press ( input , 'ArrowDown' )
113116 assert . equal ( options [ 4 ] . getAttribute ( 'aria-selected' ) , 'true' )
114117 assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'wall-e' )
115118 press ( input , 'Enter' )
116119 click ( document . getElementById ( 'wall-e' ) )
117120
118- press ( input , 'ArrowDown' )
121+ ctrlBindings ? press ( input , 'n' , true ) : press ( input , 'ArrowDown' )
119122 assert . equal ( options [ 5 ] . getAttribute ( 'aria-selected' ) , 'true' )
120123 assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'link' )
121124
@@ -127,19 +130,18 @@ describe('combobox-nav', function() {
127130 assert . equal ( options [ 0 ] . getAttribute ( 'aria-selected' ) , 'true' )
128131 assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'baymax' )
129132
130- press ( input , 'ArrowUp' )
133+ ctrlBindings ? press ( input , 'p' , true ) : press ( input , 'ArrowUp' )
131134 assert ( ! list . querySelector ( '[aria-selected=true]' ) , 'Nothing should be selected' )
132135 assert ( ! input . hasAttribute ( 'aria-activedescendant' ) , 'Nothing should be selected' )
133136
134- press ( input , 'ArrowDown' )
135- press ( input , 'ArrowDown' )
136- assert . equal ( options [ 1 ] . getAttribute ( 'aria-selected' ) , 'true' )
137- assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'hubot' )
137+ press ( input , 'ArrowUp' )
138+ assert . equal ( options [ 5 ] . getAttribute ( 'aria-selected' ) , 'true' )
139+ assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'link' )
138140
139141 press ( input , 'Enter' )
140142 assert . equal ( expectedTargets . length , 2 )
141143 assert . equal ( expectedTargets [ 0 ] , 'hubot' )
142- assert . equal ( expectedTargets [ 1 ] , 'hubot ' )
144+ assert . equal ( expectedTargets [ 1 ] , 'link ' )
143145 } )
144146
145147 it ( 'fires commit events on click' , function ( ) {
@@ -171,6 +173,10 @@ describe('combobox-nav', function() {
171173 assert . equal ( options [ 0 ] . getAttribute ( 'aria-selected' ) , 'true' )
172174 assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'baymax' )
173175
176+ press ( input , 'Control' , true )
177+ assert . equal ( options [ 0 ] . getAttribute ( 'aria-selected' ) , 'true' , 'Selection stays on modifier keydown' )
178+ assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'baymax' , 'Selection stays on modifier keydown' )
179+
174180 press ( input , 'Backspace' )
175181 assert ( ! list . querySelector ( '[aria-selected=true]' ) , 'Nothing should be selected' )
176182 assert ( ! input . hasAttribute ( 'aria-activedescendant' ) , 'Nothing should be selected' )
0 commit comments