summaryrefslogtreecommitdiff
path: root/stowables-dotlocal/share/nvim/site/pack/manual/start/nvim-cmp-v0.0.1/lua/cmp/context_spec.lua
blob: 976e194a443b11c43d9130a27663ca9826b59773 (plain)
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
local spec = require('cmp.utils.spec')

local context = require('cmp.context')

describe('context', function()
  before_each(spec.before)

  describe('new', function()
    it('middle of text', function()
      vim.fn.setline('1', 'function! s:name() abort')
      vim.bo.filetype = 'vim'
      vim.fn.execute('normal! fm')
      local ctx = context.new()
      assert.are.equal(ctx.filetype, 'vim')
      assert.are.equal(ctx.cursor.row, 1)
      assert.are.equal(ctx.cursor.col, 15)
      assert.are.equal(ctx.cursor_line, 'function! s:name() abort')
    end)

    it('tab indent', function()
      vim.fn.setline('1', '\t\tab')
      vim.bo.filetype = 'vim'
      vim.fn.execute('normal! fb')
      local ctx = context.new()
      assert.are.equal(ctx.filetype, 'vim')
      assert.are.equal(ctx.cursor.row, 1)
      assert.are.equal(ctx.cursor.col, 4)
      assert.are.equal(ctx.cursor_line, '\t\tab')
    end)
  end)
end)