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 command-mode initially by default", ->
22 expect(editorElement.classList.contains('vim-mode')).toBe(true)
23 expect(editorElement.classList.contains('command-mode')).toBe(true)
25 it "shows the current vim mode in the status bar", ->
26 statusBarTile = workspaceElement.querySelector("#status-bar-vim-mode")
27 expect(statusBarTile.textContent).toBe("Command")
28 atom.commands.dispatch(editorElement, "vim-mode:activate-insert-mode")
29 expect(statusBarTile.textContent).toBe("Insert")
31 it "doesn't register duplicate command listeners for editors", ->
32 editor.setText("12345")
33 editor.setCursorBufferPosition([0, 0])
35 pane = atom.workspace.getActivePane()
36 newPane = pane.splitRight()
37 pane.removeItem(editor)
38 newPane.addItem(editor)
40 atom.commands.dispatch(editorElement, "vim-mode:move-right")
41 expect(editor.getCursorBufferPosition()).toEqual([0, 1])
43 describe ".deactivate", ->
44 it "removes the vim classes from the editor", ->
45 atom.packages.deactivatePackage('vim-mode')
46 expect(editorElement.classList.contains("vim-mode")).toBe(false)
47 expect(editorElement.classList.contains("command-mode")).toBe(false)
49 it "removes the vim commands from the editor element", ->
51 atom.commands.findCommands(target: editorElement).filter (cmd) ->
52 cmd.name.startsWith("vim-mode:")
54 expect(vimCommands().length).toBeGreaterThan(0)
55 atom.packages.deactivatePackage('vim-mode')
56 expect(vimCommands().length).toBe(0)