Move GlobalKeymap instance to App. Clear bindings between examples.

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-01-11 11:42:22 -08:00
parent 766f301bc1
commit 1aa99c379f
5 changed files with 19 additions and 10 deletions

View File

@@ -10,6 +10,7 @@ describe "RootView", ->
beforeEach ->
url = require.resolve 'fixtures/dir/a'
rootView = RootView.build {url}
rootView.enableKeymap()
project = rootView.project
describe "initialize", ->
@@ -86,7 +87,7 @@ describe "RootView", ->
beforeEach ->
commandHandler = jasmine.createSpy('commandHandler')
rootView.on('foo-command', commandHandler)
rootView.globalKeymap.bindKeys('*', 'x': 'foo-command')
atom.globalKeymap.bindKeys('*', 'x': 'foo-command')
describe "when a key is typed in the editor that has a binding in the keymap", ->
it "triggers the key binding's command as an event and stops its propagation", ->
@@ -99,6 +100,7 @@ describe "RootView", ->
describe "when a keydown event is triggered on the RootView (not originating from Ace)", ->
it "triggers matching keybindings for that event", ->
event = keydownEvent 'x', target: rootView[0]
rootView.trigger(event)
expect(commandHandler).toHaveBeenCalled()

View File

@@ -6,6 +6,7 @@ BindingSet = require 'binding-set'
afterEach ->
(new Native).resetMainMenu()
atom.globalKeymap.reset()
window.atom = new (require 'app')
@@ -25,3 +26,7 @@ $.fn.resultOfTrigger = (type) ->
event = $.Event(type)
this.trigger(event)
event.result
$.fn.enableKeymap = ->
@on 'keydown', (e) => atom.globalKeymap.handleKeyEvent(e)