aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Hinz <mh.codebro@gmail.com>2019-03-29 02:08:57 +0100
committerMarco Hinz <mh.codebro@gmail.com>2019-03-29 10:58:53 +0100
commit33d4c381315412b52e3e2867d37ac0851e3d0faf (patch)
treed43f4b3fd138692012419c775b8e3686931085ac
parente2839d96330210ab1c66315dc90a3e0f7ac3e869 (diff)
downloadrneovim-33d4c381315412b52e3e2867d37ac0851e3d0faf.tar.gz
rneovim-33d4c381315412b52e3e2867d37ac0851e3d0faf.tar.bz2
rneovim-33d4c381315412b52e3e2867d37ac0851e3d0faf.zip
cursormoved: add tests for CursorMoved
-rw-r--r--test/functional/autocmd/cursormoved_spec.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/functional/autocmd/cursormoved_spec.lua b/test/functional/autocmd/cursormoved_spec.lua
new file mode 100644
index 0000000000..d0f46e689b
--- /dev/null
+++ b/test/functional/autocmd/cursormoved_spec.lua
@@ -0,0 +1,34 @@
+local helpers = require('test.functional.helpers')(after_each)
+
+local clear = helpers.clear
+local eq = helpers.eq
+local eval = helpers.eval
+local funcs = helpers.funcs
+local source = helpers.source
+
+describe('CursorMoved', function()
+ before_each(clear)
+
+ it('is triggered by changing windows', function()
+ source([[
+ let g:cursormoved = 0
+ vsplit
+ autocmd CursorMoved * let g:cursormoved += 1
+ wincmd w
+ wincmd w
+ ]])
+ eq(2, eval('g:cursormoved'))
+ end)
+
+ it("is not triggered by functions that don't change the window", function()
+ source([[
+ let g:cursormoved = 0
+ let g:buf = bufnr('%')
+ vsplit foo
+ autocmd CursorMoved * let g:cursormoved += 1
+ call nvim_buf_set_lines(g:buf, 0, -1, v:true, ['aaa'])
+ ]])
+ eq({'aaa'}, funcs.nvim_buf_get_lines(eval('g:buf'), 0, -1, true))
+ eq(0, eval('g:cursormoved'))
+ end)
+end)