pulsar/spec/atom/binding-set-spec.coffee
Corey Johnson a41676e84e Use event.originalEvent.keyIdentifier instead of event.which.
Events match patterns if event.keyStroke == key pattern.
2012-02-15 10:04:02 -08:00

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()