aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/window_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2024-12-16 08:34:16 -0800
committerGitHub <noreply@github.com>2024-12-16 08:34:16 -0800
commit022449b5223659d515b78bada7de2fac8718820a (patch)
tree2ce4dd7b21d2ba4089308b877608f4dbc4166d99 /test/functional/api/window_spec.lua
parentfb8372adb3b9f50d4d18eba6f650c3728353ab00 (diff)
downloadrneovim-022449b5223659d515b78bada7de2fac8718820a.tar.gz
rneovim-022449b5223659d515b78bada7de2fac8718820a.tar.bz2
rneovim-022449b5223659d515b78bada7de2fac8718820a.zip
fix(api): generic error messages, not using TRY_WRAP #31596
Problem: - API functions using `try_start` directly, do not surface the underlying error message, and instead show generic messages. - Error-handling code is duplicated in the API impl. - Failure modes are not tested. Solution: - Use `TRY_WRAP`. - Add tests.
Diffstat (limited to 'test/functional/api/window_spec.lua')
-rw-r--r--test/functional/api/window_spec.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua
index 4662ace4bf..078d581b6f 100644
--- a/test/functional/api/window_spec.lua
+++ b/test/functional/api/window_spec.lua
@@ -359,6 +359,15 @@ describe('API/win', function()
eq(2, api.nvim_win_get_height(api.nvim_list_wins()[2]))
end)
+ it('failure modes', function()
+ command('split')
+ eq('Invalid window id: 999999', pcall_err(api.nvim_win_set_height, 999999, 10))
+ eq(
+ 'Wrong type for argument 2 when calling nvim_win_set_height, expecting Integer',
+ pcall_err(api.nvim_win_set_height, 0, 0.9)
+ )
+ end)
+
it('correctly handles height=1', function()
command('split')
api.nvim_set_current_win(api.nvim_list_wins()[1])
@@ -409,6 +418,15 @@ describe('API/win', function()
eq(2, api.nvim_win_get_width(api.nvim_list_wins()[2]))
end)
+ it('failure modes', function()
+ command('vsplit')
+ eq('Invalid window id: 999999', pcall_err(api.nvim_win_set_width, 999999, 10))
+ eq(
+ 'Wrong type for argument 2 when calling nvim_win_set_width, expecting Integer',
+ pcall_err(api.nvim_win_set_width, 0, 0.9)
+ )
+ end)
+
it('do not cause ml_get errors with foldmethod=expr #19989', function()
insert([[
aaaaa