1
1
import Combobox from '../dist/index.js'
2
+
3
+ const ctrlBindings = ! ! navigator . userAgent . match ( / M a c i n t o s h / )
4
+
2
5
function press ( input , key , ctrlKey ) {
3
6
input . dispatchEvent ( new KeyboardEvent ( 'keydown' , { key, ctrlKey} ) )
4
7
}
@@ -105,17 +108,17 @@ describe('combobox-nav', function() {
105
108
106
109
press ( input , 'Enter' )
107
110
108
- press ( input , 'ArrowDown' )
111
+ ctrlBindings ? press ( input , 'n' , true ) : press ( input , 'ArrowDown' )
109
112
assert . equal ( options [ 2 ] . getAttribute ( 'aria-selected' ) , 'true' )
110
113
assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'r2-d2' )
111
114
112
- press ( input , 'ArrowDown' )
115
+ ctrlBindings ? press ( input , 'n' , true ) : press ( input , 'ArrowDown' )
113
116
assert . equal ( options [ 4 ] . getAttribute ( 'aria-selected' ) , 'true' )
114
117
assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'wall-e' )
115
118
press ( input , 'Enter' )
116
119
click ( document . getElementById ( 'wall-e' ) )
117
120
118
- press ( input , 'ArrowDown' )
121
+ ctrlBindings ? press ( input , 'n' , true ) : press ( input , 'ArrowDown' )
119
122
assert . equal ( options [ 5 ] . getAttribute ( 'aria-selected' ) , 'true' )
120
123
assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'link' )
121
124
@@ -127,19 +130,18 @@ describe('combobox-nav', function() {
127
130
assert . equal ( options [ 0 ] . getAttribute ( 'aria-selected' ) , 'true' )
128
131
assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'baymax' )
129
132
130
- press ( input , 'ArrowUp' )
133
+ ctrlBindings ? press ( input , 'p' , true ) : press ( input , 'ArrowUp' )
131
134
assert ( ! list . querySelector ( '[aria-selected=true]' ) , 'Nothing should be selected' )
132
135
assert ( ! input . hasAttribute ( 'aria-activedescendant' ) , 'Nothing should be selected' )
133
136
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' )
138
140
139
141
press ( input , 'Enter' )
140
142
assert . equal ( expectedTargets . length , 2 )
141
143
assert . equal ( expectedTargets [ 0 ] , 'hubot' )
142
- assert . equal ( expectedTargets [ 1 ] , 'hubot ' )
144
+ assert . equal ( expectedTargets [ 1 ] , 'link ' )
143
145
} )
144
146
145
147
it ( 'fires commit events on click' , function ( ) {
@@ -171,6 +173,10 @@ describe('combobox-nav', function() {
171
173
assert . equal ( options [ 0 ] . getAttribute ( 'aria-selected' ) , 'true' )
172
174
assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'baymax' )
173
175
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
+
174
180
press ( input , 'Backspace' )
175
181
assert ( ! list . querySelector ( '[aria-selected=true]' ) , 'Nothing should be selected' )
176
182
assert ( ! input . hasAttribute ( 'aria-activedescendant' ) , 'Nothing should be selected' )
0 commit comments