diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-08-21 13:45:26 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-08-21 14:16:16 +0800 |
commit | 6aa29d0f01e715fe51de4f66dee377e4c1726229 (patch) | |
tree | 39f1120f66af1d5fb573241d06ce5d2d70d9a028 | |
parent | 4b0a13b455e6218514bfc67da0bb375529b4d4d7 (diff) | |
download | rneovim-6aa29d0f01e715fe51de4f66dee377e4c1726229.tar.gz rneovim-6aa29d0f01e715fe51de4f66dee377e4c1726229.tar.bz2 rneovim-6aa29d0f01e715fe51de4f66dee377e4c1726229.zip |
test: add some tests for SafeState autocommand
-rw-r--r-- | test/functional/autocmd/safestate_spec.lua | 57 | ||||
-rw-r--r-- | test/functional/vimscript/state_spec.lua | 1 |
2 files changed, 57 insertions, 1 deletions
diff --git a/test/functional/autocmd/safestate_spec.lua b/test/functional/autocmd/safestate_spec.lua new file mode 100644 index 0000000000..73693749e4 --- /dev/null +++ b/test/functional/autocmd/safestate_spec.lua @@ -0,0 +1,57 @@ +local helpers = require('test.functional.helpers')(after_each) +local clear = helpers.clear +local eq = helpers.eq +local exec = helpers.exec +local feed = helpers.feed +local meths = helpers.meths + +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, meths.get_var('safe')) + feed('d') + eq(1, meths.get_var('safe')) + end) + + it('with specified register', function() + feed('"r') + create_autocmd() + eq(0, meths.get_var('safe')) + feed('x') + eq(1, meths.get_var('safe')) + end) + + it('with i_CTRL-O', function() + feed('i<C-O>') + create_autocmd() + eq(0, meths.get_var('safe')) + feed('x') + eq(1, meths.get_var('safe')) + end) + + it('with Insert mode completion', function() + feed('i<C-X><C-V>') + create_autocmd() + eq(0, meths.get_var('safe')) + feed('<C-X><C-Z>') + eq(1, meths.get_var('safe')) + end) + + it('with Cmdline completion', function() + feed(':<Tab>') + create_autocmd() + eq(0, meths.get_var('safe')) + feed('<C-E>') + eq(1, meths.get_var('safe')) + end) +end) diff --git a/test/functional/vimscript/state_spec.lua b/test/functional/vimscript/state_spec.lua index fd38a8ad5b..70f68a7494 100644 --- a/test/functional/vimscript/state_spec.lua +++ b/test/functional/vimscript/state_spec.lua @@ -17,7 +17,6 @@ describe('state() function', function() function _G.Get_state_mode() _G.res = { vim.fn.state(), vim.api.nvim_get_mode().mode:sub(1, 1) } end - function _G.Run_timer() local timer = vim.uv.new_timer() timer:start(0, 0, function() |