Use closure wrapper with current event name

This commit is contained in:
Kevin Sawicki
2012-10-04 11:07:46 -07:00
parent 863f9f36fb
commit ceb496e202
2 changed files with 7 additions and 1 deletions

View File

@@ -114,12 +114,14 @@ describe "EditorCommand", ->
it "registers all keymaps", ->
callbackCount = 0
eventName = null
class CustomCommand extends EditorCommand
@getKeymaps: (editor) ->
'meta-V': 'custom1'
'meta-B': 'custom2'
@execute: (editor, event) ->
eventName = event
@replaceSelectedText editor, (text) ->
callbackCount++
text
@@ -129,7 +131,9 @@ describe "EditorCommand", ->
editor.selectToEndOfLine()
editor.trigger 'custom1'
expect(callbackCount).toBe 1
expect(eventName).toBe 'custom1'
editor.trigger 'custom2'
expect(eventName).toBe 'custom2'
expect(callbackCount).toBe 2
describe "LowerCaseCommand", ->