]> git.r.bdr.sh - rbdr/dotfiles/blame_incremental - atom/packages/vim-mode/spec/insert-mode-spec.coffee
Updates syntastic
[rbdr/dotfiles] / atom / packages / vim-mode / spec / insert-mode-spec.coffee
... / ...
CommitLineData
1helpers = require './spec-helper'
2
3describe "Insert mode commands", ->
4 [editor, editorElement, vimState] = []
5
6 beforeEach ->
7 vimMode = atom.packages.loadPackage('vim-mode')
8 vimMode.activateResources()
9
10 helpers.getEditorElement (element) ->
11 editorElement = element
12 editor = editorElement.getModel()
13 vimState = editorElement.vimState
14 vimState.activateNormalMode()
15 vimState.resetNormalMode()
16
17 keydown = (key, options={}) ->
18 options.element ?= editorElement
19 helpers.keydown(key, options)
20
21 describe "Copy from line above/below", ->
22 beforeEach ->
23 editor.setText("12345\n\nabcd\nefghi")
24 editor.setCursorBufferPosition([1, 0])
25 editor.addCursorAtBufferPosition([3, 0])
26 keydown 'i'
27
28 describe "the ctrl-y command", ->
29 it "copies from the line above", ->
30 keydown 'y', ctrl: true
31 expect(editor.getText()).toBe '12345\n1\nabcd\naefghi'
32
33 editor.insertText ' '
34 keydown 'y', ctrl: true
35 expect(editor.getText()).toBe '12345\n1 3\nabcd\na cefghi'
36
37 it "does nothing if there's nothing above the cursor", ->
38 editor.insertText 'fill'
39 keydown 'y', ctrl: true
40 expect(editor.getText()).toBe '12345\nfill5\nabcd\nfillefghi'
41
42 keydown 'y', ctrl: true
43 expect(editor.getText()).toBe '12345\nfill5\nabcd\nfillefghi'
44
45 it "does nothing on the first line", ->
46 editor.setCursorBufferPosition([0, 2])
47 editor.addCursorAtBufferPosition([3, 2])
48 editor.insertText 'a'
49 expect(editor.getText()).toBe '12a345\n\nabcd\nefaghi'
50 keydown 'y', ctrl: true
51 expect(editor.getText()).toBe '12a345\n\nabcd\nefadghi'
52
53 describe "the ctrl-e command", ->
54 beforeEach ->
55 atom.keymaps.add "test",
56 'atom-text-editor.vim-mode.insert-mode':
57 'ctrl-e': 'vim-mode:copy-from-line-below'
58
59 it "copies from the line below", ->
60 keydown 'e', ctrl: true
61 expect(editor.getText()).toBe '12345\na\nabcd\nefghi'
62
63 editor.insertText ' '
64 keydown 'e', ctrl: true
65 expect(editor.getText()).toBe '12345\na c\nabcd\n efghi'
66
67 it "does nothing if there's nothing below the cursor", ->
68 editor.insertText 'foo'
69 keydown 'e', ctrl: true
70 expect(editor.getText()).toBe '12345\nfood\nabcd\nfooefghi'
71
72 keydown 'e', ctrl: true
73 expect(editor.getText()).toBe '12345\nfood\nabcd\nfooefghi'