mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-11 04:48:44 +03:00
a41676e84e
Events match patterns if event.keyStroke == key pattern.
21 lines
1.0 KiB
CoffeeScript
21 lines
1.0 KiB
CoffeeScript
$ = require 'jquery'
|
|
_ = require 'underscore'
|
|
BindingSet = require 'binding-set'
|
|
|
|
describe "BindingSet", ->
|
|
bindingSet = null
|
|
beforeEach ->
|
|
bindingSet = new BindingSet('*', 'x': 'foo')
|
|
|
|
describe ".eventMatchesPattern(event, pattern)", ->
|
|
it "handles patterns with and without modifiers", ->
|
|
expect(bindingSet.eventMatchesPattern(keydownEvent('q'), 'q')).toBeTruthy()
|
|
expect(bindingSet.eventMatchesPattern(keydownEvent('left'), 'left')).toBeTruthy()
|
|
expect(bindingSet.eventMatchesPattern(keydownEvent('0', altKey: true), '<alt-0>')).toBeTruthy()
|
|
expect(bindingSet.eventMatchesPattern(keydownEvent('A', shiftKey: true), 'A')).toBeTruthy()
|
|
expect(bindingSet.eventMatchesPattern(keydownEvent('0', altKey: true, ctrlKey: true, metaKey: true, shiftKey: true), '<alt-ctrl-meta-0>')).toBeTruthy()
|
|
|
|
# negative examples
|
|
expect(bindingSet.eventMatchesPattern(keydownEvent('a'), '<shift-a>')).toBeFalsy()
|
|
expect(bindingSet.eventMatchesPattern(keydownEvent('d'), 'k')).toBeFalsy()
|