File: safestate_spec.lua

package info (click to toggle)
neovim 0.11.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 64,140 kB
  • sloc: ansic: 263,427; python: 1,472; lisp: 1,237; sh: 1,138; makefile: 382; xml: 84; ruby: 6
file content (59 lines) | stat: -rw-r--r-- 1,267 bytes parent folder | download | duplicates (3)
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
local t = require('test.testutil')
local n = require('test.functional.testnvim')()

local clear = n.clear
local eq = t.eq
local exec = n.exec
local feed = n.feed
local api = n.api

before_each(clear)

describe('SafeState autocommand', function()
  local function create_autocmd()
    exec([[
      let g:safe = 0
      autocmd SafeState * ++once let g:safe += 1
    ]])
  end

  it('with pending operator', function()
    feed('d')
    create_autocmd()
    eq(0, api.nvim_get_var('safe'))
    feed('d')
    eq(1, api.nvim_get_var('safe'))
  end)

  it('with specified register', function()
    feed('"r')
    create_autocmd()
    eq(0, api.nvim_get_var('safe'))
    feed('x')
    eq(1, api.nvim_get_var('safe'))
  end)

  it('with i_CTRL-O', function()
    feed('i<C-O>')
    create_autocmd()
    eq(0, api.nvim_get_var('safe'))
    feed('x')
    eq(1, api.nvim_get_var('safe'))
  end)

  it('with Insert mode completion', function()
    feed('i<C-X><C-V>')
    create_autocmd()
    eq(0, api.nvim_get_var('safe'))
    feed('<C-X><C-Z>')
    eq(1, api.nvim_get_var('safe'))
  end)

  it('with Cmdline completion', function()
    feed(':<Tab>')
    create_autocmd()
    eq(0, api.nvim_get_var('safe'))
    feed('<C-E>')
    eq(1, api.nvim_get_var('safe'))
  end)
end)