aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/health_spec.lua
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2024-04-02 15:45:19 +0200
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2024-04-04 13:10:11 +0200
commite016f5bee6293d126fde9e8d75a3f02f882e2c81 (patch)
tree05a21a41b1c0c934e6fbf508a213f222ad3a60c1 /test/functional/plugin/health_spec.lua
parent56701cd21e1ded488872fa82d2b56734495b1fe2 (diff)
downloadrneovim-e016f5bee6293d126fde9e8d75a3f02f882e2c81.tar.gz
rneovim-e016f5bee6293d126fde9e8d75a3f02f882e2c81.tar.bz2
rneovim-e016f5bee6293d126fde9e8d75a3f02f882e2c81.zip
test: reduce `exec_lua` calls
`exec_lua` makes code slighly harder to read, so it's beneficial to remove it in cases where it's possible or convenient. Not all `exec_lua` calls should be removed even if the test passes as it changes the semantics of the test even if it happens to pass. From https://github.com/neovim/neovim/pull/28155#discussion_r1548185779: "Note for tests like this, which fundamentally are about conversion, you end up changing what conversion you are testing. Even if the result happens to be same (as they often are, as we like the rules to be consistent if possible), you are now testing the RPC conversion rules instead of the vim script to in-process lua conversion rules." From https://github.com/neovim/neovim/pull/28155#discussion_r1548190152: "A test like this specifies that the cursor is valid immediately and not after a separate cycle of normal (or an other input-processing) mode."
Diffstat (limited to 'test/functional/plugin/health_spec.lua')
-rw-r--r--test/functional/plugin/health_spec.lua7
1 files changed, 4 insertions, 3 deletions
diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua
index 9306180c40..8416f0e5f7 100644
--- a/test/functional/plugin/health_spec.lua
+++ b/test/functional/plugin/health_spec.lua
@@ -8,7 +8,8 @@ local eq, neq, matches = helpers.eq, helpers.neq, helpers.matches
local getcompletion = helpers.fn.getcompletion
local insert = helpers.insert
local source = helpers.source
-local exec_lua = helpers.exec_lua
+local fn = helpers.fn
+local api = helpers.api
describe(':checkhealth', function()
it('detects invalid $VIMRUNTIME', function()
@@ -381,7 +382,7 @@ describe(':checkhealth window', function()
it('opens in tab', function()
-- create an empty buffer called "my_buff"
- exec_lua 'vim.api.nvim_create_buf(false, true)'
+ api.nvim_create_buf(false, true)
command('file my_buff')
command('checkhealth success1')
-- define a function that collects all buffers in each tab
@@ -400,7 +401,7 @@ describe(':checkhealth window', function()
return buffs
endfunction
]])
- local buffers_per_tab = exec_lua('return vim.fn.CollectBuffersPerTab()')
+ local buffers_per_tab = fn.CollectBuffersPerTab()
eq(buffers_per_tab, { tab1 = { 'my_buff' }, tab2 = { 'health://' } })
end)
end)