diff --git a/spec/window-spec.coffee b/spec/window-spec.coffee index 94e605a36..d56d087b1 100644 --- a/spec/window-spec.coffee +++ b/spec/window-spec.coffee @@ -1,4 +1,5 @@ {$, $$} = require '../src/space-pen-extensions' +KeymapManager = require 'atom-keymap' path = require 'path' fs = require 'fs-plus' temp = require 'temp' @@ -304,3 +305,16 @@ describe "Window", -> runs -> expect(atom.project.getPaths()[0]).toBe pathToOpen + + describe "when keydown events occur on the document", -> + it "dispatches the event via the KeymapManager and CommandRegistry", -> + dispatchedCommands = [] + atom.commands.onWillDispatch (command) -> dispatchedCommands.push(command) + atom.commands.add '*', 'foo-command': -> + atom.keymaps.add 'source-name', '*': {'x': 'foo-command'} + + event = KeymapManager.buildKeydownEvent('x', target: document.createElement('div')) + document.dispatchEvent(event) + + expect(dispatchedCommands.length).toBe 1 + expect(dispatchedCommands[0].type).toBe 'foo-command' diff --git a/spec/workspace-view-spec.coffee b/spec/workspace-view-spec.coffee index b667b04db..14d1e76e8 100644 --- a/spec/workspace-view-spec.coffee +++ b/spec/workspace-view-spec.coffee @@ -36,17 +36,6 @@ describe "WorkspaceView", -> atom.workspaceView.focus() expect(activePane).toHaveFocus() - describe "keymap wiring", -> - describe "when a keydown event is triggered in the WorkspaceView", -> - it "triggers matching keybindings for that event", -> - commandHandler = jasmine.createSpy('commandHandler') - atom.workspaceView.on('foo-command', commandHandler) - atom.keymaps.add('name', '*': {'x': 'foo-command'}) - event = keydownEvent 'x', target: atom.workspaceView[0] - - atom.workspaceView.trigger(event) - expect(commandHandler).toHaveBeenCalled() - describe "window:toggle-invisibles event", -> it "shows/hides invisibles in all open and future editors", -> atom.workspaceView.height(200)