mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Basic test for user keymap loaded event
This commit is contained in:
23
spec/keymap-extensions-spec.coffee
Normal file
23
spec/keymap-extensions-spec.coffee
Normal file
@@ -0,0 +1,23 @@
|
||||
path = require 'path'
|
||||
temp = require('temp').track()
|
||||
CSON = require 'season'
|
||||
fs = require 'fs-plus'
|
||||
|
||||
describe "keymap-extensions", ->
|
||||
|
||||
beforeEach ->
|
||||
atom.keymaps.configDirPath = temp.path('atom-spec-keymap-ext')
|
||||
fs.writeFileSync(atom.keymaps.getUserKeymapPath(), '#')
|
||||
@userKeymapLoaded = ->
|
||||
atom.keymaps.onDidLoadUserKeymap => @userKeymapLoaded()
|
||||
|
||||
afterEach ->
|
||||
fs.removeSync(atom.keymaps.configDirPath)
|
||||
atom.keymaps.destroy()
|
||||
|
||||
describe "did-load-user-keymap", ->
|
||||
|
||||
it "fires when user keymap is loaded", ->
|
||||
spyOn(this, 'userKeymapLoaded')
|
||||
atom.keymaps.loadUserKeymap()
|
||||
expect(@userKeymapLoaded).toHaveBeenCalled()
|
||||
@@ -35,10 +35,8 @@ KeymapManager::loadUserKeymap = ->
|
||||
return unless fs.isFileSync(userKeymapPath)
|
||||
|
||||
try
|
||||
errorLoading = false
|
||||
@loadKeymap(userKeymapPath, watch: true, suppressErrors: true, priority: 100)
|
||||
catch error
|
||||
errorLoading = true
|
||||
if error.message.indexOf('Unable to watch path') > -1
|
||||
message = """
|
||||
Unable to watch path: `#{path.basename(userKeymapPath)}`. Make sure you
|
||||
@@ -54,7 +52,7 @@ KeymapManager::loadUserKeymap = ->
|
||||
stack = error.stack
|
||||
@notificationManager.addFatalError(error.message, {detail, stack, dismissable: true})
|
||||
|
||||
@emitter.emit 'did-load-user-keymap' unless errorLoading
|
||||
@emitter.emit 'did-load-user-keymap'
|
||||
|
||||
|
||||
KeymapManager::subscribeToFileReadFailure = ->
|
||||
|
||||
Reference in New Issue
Block a user