@@ -34,12 +34,12 @@ describe("HotkeysParser", () => {
34
34
parsedKeyCombo : KeyCombo ;
35
35
}
36
36
37
- const makeComboTest = ( combo : string , event : KeyboardEvent ) => {
37
+ const makeComboTest = ( combo : string , event : Partial < KeyboardEvent > ) => {
38
38
return {
39
39
combo,
40
- eventKeyCombo : getKeyCombo ( event ) ,
40
+ eventKeyCombo : getKeyCombo ( event as KeyboardEvent ) ,
41
41
parsedKeyCombo : parseKeyCombo ( combo ) ,
42
- stringKeyCombo : getKeyComboString ( event ) ,
42
+ stringKeyCombo : getKeyComboString ( event as KeyboardEvent ) ,
43
43
} ;
44
44
} ;
45
45
@@ -58,8 +58,7 @@ describe("HotkeysParser", () => {
58
58
Array . apply ( null , Array ( 26 ) ) . map ( ( _ : any , i : number ) => {
59
59
const charString = String . fromCharCode ( alpha + i ) . toLowerCase ( ) ;
60
60
const combo = charString ;
61
- const event : KeyboardEvent = { key : charString } as any ;
62
- return makeComboTest ( combo , event ) ;
61
+ return makeComboTest ( combo , { key : charString } ) ;
63
62
} ) ,
64
63
) ;
65
64
} ) ;
@@ -70,8 +69,7 @@ describe("HotkeysParser", () => {
70
69
Array . apply ( null , Array ( 26 ) ) . map ( ( _ : any , i : number ) => {
71
70
const charString = String . fromCharCode ( alpha + i ) . toLowerCase ( ) ;
72
71
const combo = charString . toUpperCase ( ) ;
73
- const event : KeyboardEvent = { key : charString } as any ;
74
- return makeComboTest ( combo , event ) ;
72
+ return makeComboTest ( combo , { key : charString } ) ;
75
73
} ) ,
76
74
false ,
77
75
) ; // don't compare string combos
@@ -83,8 +81,7 @@ describe("HotkeysParser", () => {
83
81
Array . apply ( null , Array ( 26 ) ) . map ( ( _ : any , i : number ) => {
84
82
const charString = String . fromCharCode ( alpha + i ) . toLowerCase ( ) ;
85
83
const combo = "shift + " + charString ;
86
- const event : KeyboardEvent = { shiftKey : true , key : charString } as any ;
87
- return makeComboTest ( combo , event ) ;
84
+ return makeComboTest ( combo , { shiftKey : true , key : charString } ) ;
88
85
} ) ,
89
86
) ;
90
87
} ) ;
@@ -111,9 +108,9 @@ describe("HotkeysParser", () => {
111
108
// these tests no longer make sense with the migration from key codes to named keys, they can likely be deleted
112
109
it . skip ( "adds Shift to keys that imply it" , ( ) => {
113
110
const tests = [ ] as ComboTest [ ] ;
114
- tests . push ( makeComboTest ( "!" , { shiftKey : true , key : "!" } as any as KeyboardEvent ) ) ;
115
- tests . push ( makeComboTest ( "@" , { shiftKey : true , key : "@" } as any as KeyboardEvent ) ) ;
116
- tests . push ( makeComboTest ( "{" , { shiftKey : true , key : "{" } as any as KeyboardEvent ) ) ;
111
+ tests . push ( makeComboTest ( "!" , { shiftKey : true , key : "!" } ) ) ;
112
+ tests . push ( makeComboTest ( "@" , { shiftKey : true , key : "@" } ) ) ;
113
+ tests . push ( makeComboTest ( "{" , { shiftKey : true , key : "{" } ) ) ;
117
114
// don't verify the strings because these will be converted to
118
115
// `Shift + 1`, etc.
119
116
verifyCombos ( tests , false ) ;
@@ -125,6 +122,15 @@ describe("HotkeysParser", () => {
125
122
expect ( comboMatches ( parseKeyCombo ( "cmd + plus" ) , parseKeyCombo ( "meta + plus" ) ) ) . to . be . true ;
126
123
} ) ;
127
124
125
+ it ( "handles space key" , ( ) => {
126
+ const tests = [ ] as ComboTest [ ] ;
127
+ tests . push (
128
+ makeComboTest ( "space" , { key : " " } ) ,
129
+ makeComboTest ( "ctrl + space" , { ctrlKey : true , key : " " } ) ,
130
+ ) ;
131
+ verifyCombos ( tests ) ;
132
+ } ) ;
133
+
128
134
it ( "applies aliases" , ( ) => {
129
135
expect ( comboMatches ( parseKeyCombo ( "return" ) , parseKeyCombo ( "enter" ) ) ) . to . be . true ;
130
136
0 commit comments