summaryrefslogtreecommitdiff
path: root/start/cmp/lua/cmp/context_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'start/cmp/lua/cmp/context_spec.lua')
-rw-r--r--start/cmp/lua/cmp/context_spec.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/start/cmp/lua/cmp/context_spec.lua b/start/cmp/lua/cmp/context_spec.lua
new file mode 100644
index 0000000..976e194
--- /dev/null
+++ b/start/cmp/lua/cmp/context_spec.lua
@@ -0,0 +1,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)