]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/vim-mode/spec/vim-mode-spec.coffee
Remove vim-unimpaired plugin
[rbdr/dotfiles] / atom / packages / vim-mode / spec / vim-mode-spec.coffee
1 describe "VimMode", ->
2 [editor, editorElement, workspaceElement] = []
3
4 beforeEach ->
5 workspaceElement = atom.views.getView(atom.workspace)
6
7 waitsForPromise ->
8 atom.workspace.open()
9
10 waitsForPromise ->
11 atom.packages.activatePackage('vim-mode')
12
13 waitsForPromise ->
14 atom.packages.activatePackage('status-bar')
15
16 runs ->
17 editor = atom.workspace.getActiveTextEditor()
18 editorElement = atom.views.getView(editor)
19
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)
24
25 it "shows the current vim mode in the status bar", ->
26 statusBarTile = null
27
28 waitsFor ->
29 statusBarTile = workspaceElement.querySelector("#status-bar-vim-mode")
30
31 runs ->
32 expect(statusBarTile.textContent).toBe("Normal")
33 atom.commands.dispatch(editorElement, "vim-mode:activate-insert-mode")
34 expect(statusBarTile.textContent).toBe("Insert")
35
36 it "doesn't register duplicate command listeners for editors", ->
37 editor.setText("12345")
38 editor.setCursorBufferPosition([0, 0])
39
40 pane = atom.workspace.getActivePane()
41 newPane = pane.splitRight()
42 pane.removeItem(editor)
43 newPane.addItem(editor)
44
45 atom.commands.dispatch(editorElement, "vim-mode:move-right")
46 expect(editor.getCursorBufferPosition()).toEqual([0, 1])
47
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)
53
54 it "removes the vim commands from the editor element", ->
55 vimCommands = ->
56 atom.commands.findCommands(target: editorElement).filter (cmd) ->
57 cmd.name.startsWith("vim-mode:")
58
59 expect(vimCommands().length).toBeGreaterThan(0)
60 atom.packages.deactivatePackage('vim-mode')
61 expect(vimCommands().length).toBe(0)