@@ -13,7 +13,9 @@ describe('Keyboard navigation', () => {
13
13
const t = new Thing ( ) ;
14
14
g . add ( t ) ;
15
15
simulateEvent ( 'keydown' , { key : 'Tab' } , document . querySelector ( '#game' ) ) ;
16
- const button = document . querySelector ( 'button' ) ;
16
+ const button = document . getElementById (
17
+ HIDDEN_KEYBOARD_NAVIGATION_DOM_ELEMENT_ID ( t . _id )
18
+ ) ;
17
19
expect ( button ) . not . toBeNull ( ) ;
18
20
button . dispatchEvent ( new Event ( 'focus' ) ) ;
19
21
expect ( button . textContent ) . toEqual ( t . describe ( ) ) ;
@@ -23,7 +25,9 @@ describe('Keyboard navigation', () => {
23
25
const t = new Thing ( ) ;
24
26
g . add ( t ) ;
25
27
simulateEvent ( 'keydown' , { key : 'Tab' } , document . querySelector ( '#game' ) ) ;
26
- const button = document . querySelector ( 'button' ) ;
28
+ const button = document . getElementById (
29
+ HIDDEN_KEYBOARD_NAVIGATION_DOM_ELEMENT_ID ( t . _id )
30
+ ) ;
27
31
expect ( button . style . cssText . replace ( / \s + / g, '' ) ) . toEqual (
28
32
KEYBOARD_NAVIGATION_DOM_ELEMENT_STYLE . replace ( / \s + / g, '' )
29
33
) ;
@@ -32,8 +36,10 @@ describe('Keyboard navigation', () => {
32
36
const g = new Graphics ( ) ;
33
37
const t = new Thing ( ) ;
34
38
g . add ( t ) ;
35
- simulateEvent ( 'keydown' , { key : 'Tab' } , document . querySelector ( '#game' ) ) ;
36
- const button = document . querySelector ( 'button' ) ;
39
+ simulateEvent ( 'keydown' , { key : 'Tab' } , window ) ;
40
+ const button = document . getElementById (
41
+ HIDDEN_KEYBOARD_NAVIGATION_DOM_ELEMENT_ID ( t . _id )
42
+ ) ;
37
43
expect ( button . style . cssText . replace ( / \s + / g, '' ) ) . toEqual (
38
44
KEYBOARD_NAVIGATION_DOM_ELEMENT_STYLE . replace ( / \s + / g, '' )
39
45
) ;
0 commit comments