Mailspring/spec/nylas-test-utils.coffee
Evan Morikawa 455b418d6f feat(keymap): add new <KeymapHandlers />
Summary:
Refactor keymaps to wrap components with a <KeymapHandlers /> component.
This more Reactful way of declaring keyback handlers prevents us from
needing to subscribe to `atom.commands`

Test Plan: new tests

Reviewers: bengotow, juan

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2226
2015-11-06 11:47:06 -08:00

20 lines
572 B
CoffeeScript

# Utils for testing.
CSON = require 'season'
KeymapManager = require 'atom-keymap'
NylasTestUtils =
loadKeymap: (keymapPath) ->
{resourcePath} = atom.getLoadSettings()
basePath = CSON.resolve("#{resourcePath}/keymaps/base")
atom.keymaps.loadKeymap(basePath)
if keymapPath?
keymapPath = CSON.resolve("#{resourcePath}/#{keymapPath}")
atom.keymaps.loadKeymap(keymapPath)
keyPress: (key, target) ->
event = KeymapManager.buildKeydownEvent(key, target: target)
atom.keymaps.handleKeyboardEvent(event)
module.exports = NylasTestUtils