1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
describe "VimMode", ->
[editor, editorElement, workspaceElement] = []
beforeEach ->
workspaceElement = atom.views.getView(atom.workspace)
waitsForPromise ->
atom.workspace.open()
waitsForPromise ->
atom.packages.activatePackage('vim-mode')
waitsForPromise ->
atom.packages.activatePackage('status-bar')
runs ->
editor = atom.workspace.getActiveTextEditor()
editorElement = atom.views.getView(editor)
describe ".activate", ->
it "puts the editor in normal-mode initially by default", ->
expect(editorElement.classList.contains('vim-mode')).toBe(true)
expect(editorElement.classList.contains('normal-mode')).toBe(true)
it "shows the current vim mode in the status bar", ->
statusBarTile = null
waitsFor ->
statusBarTile = workspaceElement.querySelector("#status-bar-vim-mode")
runs ->
expect(statusBarTile.textContent).toBe("Normal")
atom.commands.dispatch(editorElement, "vim-mode:activate-insert-mode")
expect(statusBarTile.textContent).toBe("Insert")
it "doesn't register duplicate command listeners for editors", ->
editor.setText("12345")
editor.setCursorBufferPosition([0, 0])
pane = atom.workspace.getActivePane()
newPane = pane.splitRight()
pane.removeItem(editor)
newPane.addItem(editor)
atom.commands.dispatch(editorElement, "vim-mode:move-right")
expect(editor.getCursorBufferPosition()).toEqual([0, 1])
describe ".deactivate", ->
it "removes the vim classes from the editor", ->
atom.packages.deactivatePackage('vim-mode')
expect(editorElement.classList.contains("vim-mode")).toBe(false)
expect(editorElement.classList.contains("normal-mode")).toBe(false)
it "removes the vim commands from the editor element", ->
vimCommands = ->
atom.commands.findCommands(target: editorElement).filter (cmd) ->
cmd.name.startsWith("vim-mode:")
expect(vimCommands().length).toBeGreaterThan(0)
atom.packages.deactivatePackage('vim-mode')
expect(vimCommands().length).toBe(0)
|