Files
nvim-cmp/lua/cmp/utils/feedkeys_spec.lua
jmp d3a3056204 ci: fix broken tests (#1729)
feedkeys_spec.lua:
In the "backspace test spec, the backspace
setting is given an integer, but only accepts
strings. Here, I assume that 0 was intended to
set backspace to a nil value, which can be done
with the empty string. I also corrected the name
of the test spec.

core_spec.lua:
In the "textedit" test spec, the actual and
expected outputs as well as the actual and
expected end characters did not match.
2023-10-18 15:37:12 +09:00

57 lines
1.6 KiB
Lua

local spec = require('cmp.utils.spec')
local keymap = require('cmp.utils.keymap')
local feedkeys = require('cmp.utils.feedkeys')
describe('feedkeys', function()
before_each(spec.before)
it('dot-repeat', function()
local reg
feedkeys.call(keymap.t('iaiueo<Esc>'), 'nx', function()
reg = vim.fn.getreg('.')
end)
assert.are.equal(reg, keymap.t('aiueo'))
end)
it('textwidth', function()
vim.cmd([[setlocal textwidth=6]])
feedkeys.call(keymap.t('iaiueo '), 'nx')
feedkeys.call(keymap.t('aaiueoaiueo'), 'nx')
assert.are.same(vim.api.nvim_buf_get_lines(0, 0, -1, false), {
'aiueo aiueoaiueo',
})
end)
it('backspace', function()
vim.cmd([[setlocal backspace=""]])
feedkeys.call(keymap.t('iaiueo'), 'nx')
feedkeys.call(keymap.t('a<BS><BS>'), 'nx')
assert.are.same(vim.api.nvim_buf_get_lines(0, 0, -1, false), {
'aiu',
})
end)
it('testability', function()
feedkeys.call('i', 'n', function()
feedkeys.call('', 'n', function()
feedkeys.call('aiueo', 'in')
end)
feedkeys.call('', 'n', function()
feedkeys.call(keymap.t('<BS><BS><BS><BS><BS>'), 'in')
end)
feedkeys.call('', 'n', function()
feedkeys.call(keymap.t('abcde'), 'in')
end)
feedkeys.call('', 'n', function()
feedkeys.call(keymap.t('<BS><BS><BS><BS><BS>'), 'in')
end)
feedkeys.call('', 'n', function()
feedkeys.call(keymap.t('12345'), 'in')
end)
end)
feedkeys.call('', 'x')
assert.are.same(vim.api.nvim_buf_get_lines(0, 0, -1, false), { '12345' })
end)
end)