@@ -3,7 +3,10 @@ import { LogControllerTestCase } from "../../cases/log_controller_test_case"
33import { Schema , defaultSchema } from "../../../core/schema"
44import { Application } from "../../../core/application"
55
6- const customSchema = { ...defaultSchema , keyMappings : { ...defaultSchema . keyMappings , a : "a" , b : "b" } }
6+ const customSchema = {
7+ ...defaultSchema ,
8+ keyMappings : { ...defaultSchema . keyMappings , a : "a" , b : "b" } as { [ key : string ] : string } ,
9+ }
710
811export default class ActionKeyboardFilterTests extends LogControllerTestCase {
912 schema : Schema = customSchema
@@ -22,6 +25,7 @@ export default class ActionKeyboardFilterTests extends LogControllerTestCase {
2225 <button id="button8" data-action="keydown.a->a#log keydown.b->a#log2"></button>
2326 <button id="button9" data-action="keydown.shift+a->a#log keydown.a->a#log2 keydown.ctrl+shift+a->a#log3">
2427 <button id="button10" data-action="jquery.custom.event->a#log jquery.a->a#log2">
28+ <button id="button11" data-action="keydown.mod+s->a#log">
2529 </div>
2630 `
2731
@@ -177,7 +181,7 @@ export default class ActionKeyboardFilterTests extends LogControllerTestCase {
177181 this . assertActions ( { name : "log2" , identifier : "a" , eventType : "keydown" , currentTarget : button } )
178182 }
179183
180- async "test ignore event handlers associated with modifiers other than ctrol +shift+a" ( ) {
184+ async "test ignore event handlers associated with modifiers other than ctrl +shift+a" ( ) {
181185 const button = this . findElement ( "#button9" )
182186 await this . nextFrame
183187 await this . triggerKeyboardEvent ( button , "keydown" , { key : "A" , ctrlKey : true , shiftKey : true } )
@@ -197,4 +201,28 @@ export default class ActionKeyboardFilterTests extends LogControllerTestCase {
197201 await this . triggerEvent ( button , "jquery.a" )
198202 this . assertActions ( { name : "log2" , identifier : "a" , eventType : "jquery.a" , currentTarget : button } )
199203 }
204+
205+ async "test ignore event handlers associated with modifiers mod+s (macOS = Meta)" ( ) {
206+ const button = this . findElement ( "#button11" )
207+ await this . nextFrame
208+ await this . triggerKeyboardEvent ( button , "keydown" , { key : "s" , ctrlKey : true } )
209+ this . assertNoActions ( )
210+ await this . triggerKeyboardEvent ( button , "keydown" , { key : "s" , metaKey : true } )
211+ this . assertActions ( { name : "log" , identifier : "a" , eventType : "keydown" , currentTarget : button } )
212+ customSchema . keyMappings . mod = "Control" // set up for next test
213+ }
214+
215+ async "test ignore event handlers associated with modifiers mod+s (Windows = Ctrl)" ( ) {
216+ // see .mod setting in previous test (mocking Windows)
217+ this . schema = {
218+ ...this . application . schema ,
219+ keyMappings : { ...this . application . schema . keyMappings , mod : "Control" } ,
220+ }
221+ const button = this . findElement ( "#button11" )
222+ await this . nextFrame
223+ await this . triggerKeyboardEvent ( button , "keydown" , { key : "s" , metaKey : true } )
224+ this . assertNoActions ( )
225+ await this . triggerKeyboardEvent ( button , "keydown" , { key : "s" , ctrlKey : true } )
226+ this . assertActions ( { name : "log" , identifier : "a" , eventType : "keydown" , currentTarget : button } )
227+ }
200228}
0 commit comments