2 [editor, editorElement, workspaceElement] = []
5 workspaceElement = atom.views.getView(atom.workspace)
11 atom.packages.activatePackage('vim-mode')
14 atom.packages.activatePackage('status-bar')
17 editor = atom.workspace.getActiveTextEditor()
18 editorElement = atom.views.getView(editor)
20 describe ".activate", ->
21 it "puts the editor in normal-mode initially by default", ->
22 expect(editorElement.classList.contains('vim-mode')).toBe(true)
23 expect(editorElement.classList.contains('normal-mode')).toBe(true)
25 it "shows the current vim mode in the status bar", ->
29 statusBarTile = workspaceElement.querySelector("#status-bar-vim-mode")
32 expect(statusBarTile.textContent).toBe("Normal")
33 atom.commands.dispatch(editorElement, "vim-mode:activate-insert-mode")
34 expect(statusBarTile.textContent).toBe("Insert")
36 it "doesn't register duplicate command listeners for editors", ->
37 editor.setText("12345")
38 editor.setCursorBufferPosition([0, 0])
40 pane = atom.workspace.getActivePane()
41 newPane = pane.splitRight()
42 pane.removeItem(editor)
43 newPane.addItem(editor)
45 atom.commands.dispatch(editorElement, "vim-mode:move-right")
46 expect(editor.getCursorBufferPosition()).toEqual([0, 1])
48 describe ".deactivate", ->
49 it "removes the vim classes from the editor", ->
50 atom.packages.deactivatePackage('vim-mode')
51 expect(editorElement.classList.contains("vim-mode")).toBe(false)
52 expect(editorElement.classList.contains("normal-mode")).toBe(false)
54 it "removes the vim commands from the editor element", ->
56 atom.commands.findCommands(target: editorElement).filter (cmd) ->
57 cmd.name.startsWith("vim-mode:")
59 expect(vimCommands().length).toBeGreaterThan(0)
60 atom.packages.deactivatePackage('vim-mode')
61 expect(vimCommands().length).toBe(0)