X-Git-Url: https://git.r.bdr.sh/rbdr/dotfiles/blobdiff_plain/24c7594d62d8d7fbbcdb64b11ce4adc5d8e6991a..0b0de929fa98457d22cbbcee65013ec261b660e2:/atom/packages/vim-mode/spec/spec-helper.coffee diff --git a/atom/packages/vim-mode/spec/spec-helper.coffee b/atom/packages/vim-mode/spec/spec-helper.coffee index 88ba4b2..7cff2fc 100644 --- a/atom/packages/vim-mode/spec/spec-helper.coffee +++ b/atom/packages/vim-mode/spec/spec-helper.coffee @@ -3,8 +3,13 @@ GlobalVimState = require '../lib/global-vim-state' VimMode = require '../lib/vim-mode' StatusBarManager = require '../lib/status-bar-manager' +[globalVimState, statusBarManager] = [] + beforeEach -> atom.workspace ||= {} + statusBarManager = null + globalVimState = null + spyOn(atom, 'beep') getEditorElement = (callback) -> textEditor = null @@ -17,11 +22,16 @@ getEditorElement = (callback) -> element = document.createElement("atom-text-editor") element.setModel(textEditor) element.classList.add('vim-mode') - element.vimState = new VimState(element, new StatusBarManager, new GlobalVimState) + statusBarManager ?= new StatusBarManager + globalVimState ?= new GlobalVimState + element.vimState = new VimState(element, statusBarManager, globalVimState) element.addEventListener "keydown", (e) -> atom.keymaps.handleKeyboardEvent(e) + # mock parent element for the text editor + document.createElement('html').appendChild(atom.views.getView(textEditor)) + callback(element) mockPlatform = (editorElement, platform) ->