File: recording_spec.lua

package info (click to toggle)
neovim 0.11.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 64,140 kB
  • sloc: ansic: 263,427; python: 1,472; lisp: 1,237; sh: 1,138; makefile: 383; xml: 84; ruby: 6
file content (73 lines) | stat: -rw-r--r-- 1,883 bytes parent folder | download | duplicates (2)
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
62
63
64
65
66
67
68
69
70
71
72
73
local t = require('test.testutil')
local n = require('test.functional.testnvim')()

local clear = n.clear
local eq = t.eq
local eval = n.eval
local source_vim = n.source

describe('RecordingEnter', function()
  before_each(clear)
  it('works', function()
    source_vim [[
      let g:recorded = 0
      autocmd RecordingEnter * let g:recorded += 1
      call feedkeys("qqyyq", 'xt')
    ]]
    eq(1, eval('g:recorded'))
  end)

  it('gives a correct reg_recording()', function()
    source_vim [[
      let g:recording = ''
      autocmd RecordingEnter * let g:recording = reg_recording()
      call feedkeys("qqyyq", 'xt')
    ]]
    eq('q', eval('g:recording'))
  end)
end)

describe('RecordingLeave', function()
  before_each(clear)
  it('works', function()
    source_vim [[
      let g:recorded = 0
      autocmd RecordingLeave * let g:recorded += 1
      call feedkeys("qqyyq", 'xt')
    ]]
    eq(1, eval('g:recorded'))
  end)

  it('gives the correct reg_recorded()', function()
    source_vim [[
      let g:recorded = 'a'
      let g:recording = ''
      autocmd RecordingLeave * let g:recording = reg_recording()
      autocmd RecordingLeave * let g:recorded = reg_recorded()
      call feedkeys("qqyyq", 'xt')
    ]]
    eq('q', eval 'g:recording')
    eq('', eval 'g:recorded')
    eq('q', eval 'reg_recorded()')
  end)

  it('populates v:event', function()
    source_vim [[
      let g:regname = ''
      let g:regcontents = ''
      autocmd RecordingLeave * let g:regname = v:event.regname
      autocmd RecordingLeave * let g:regcontents = v:event.regcontents
      call feedkeys("qqyyq", 'xt')
    ]]
    eq('q', eval 'g:regname')
    eq('yy', eval 'g:regcontents')
  end)

  it('resets v:event', function()
    source_vim [[
      autocmd RecordingLeave * let g:event = v:event
      call feedkeys("qqyyq", 'xt')
    ]]
    eq(0, eval 'len(v:event)')
  end)
end)