aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/screen.lua
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2024-12-04 16:31:08 +0100
committerGitHub <noreply@github.com>2024-12-04 07:31:08 -0800
commite2a91876ac61b4265e62a73ea9aed37597976b85 (patch)
tree9d02c36da3206312cdb80a3da71d1595d7046996 /test/functional/ui/screen.lua
parent6551e3063043b86acc90476297645150bd198c3a (diff)
downloadrneovim-e2a91876ac61b4265e62a73ea9aed37597976b85.tar.gz
rneovim-e2a91876ac61b4265e62a73ea9aed37597976b85.tar.bz2
rneovim-e2a91876ac61b4265e62a73ea9aed37597976b85.zip
test(screen): adjust screen state per stylua #31441
Before: screen:expect({ | screen:expect({ grid = [[ | grid = [[ {10:>!}a | | line ^1 | {7: }b | | {1:~ }|*4 {10:>>}c | | ]], messages={ { {7: }^ | | content = { { "\ntest\n[O]k: ", 6, 11 } }, {1:~ }|*9 | kind = "confirm" | | } } ]] | }) }) After: screen:expect([[ | screen:expect({ {10:>!}a | | grid = [[ {7: }b | | line ^1 | {10:>>}c | | {1:~ }|*4 {7: }^ | | ]], {1:~ }|*9 | messages = { { | | content = { { "\ntest\n[O]k: ", 6, 11 } }, ]]) | kind = "confirm" | } }, | })
Diffstat (limited to 'test/functional/ui/screen.lua')
-rw-r--r--test/functional/ui/screen.lua25
1 files changed, 14 insertions, 11 deletions
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index 8e15e6c35f..f5cb914299 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -37,10 +37,10 @@
-- Tests will often share a group of extra attribute sets to expect(). Those can be
-- defined at the beginning of a test:
--
--- screen:add_extra_attr_ids {
+-- screen:add_extra_attr_ids({
-- [100] = { background = Screen.colors.Plum1, underline = true },
-- [101] = { background = Screen.colors.Red1, bold = true, underline = true },
--- }
+-- })
--
-- To help write screen tests, see Screen:snapshot_util().
-- To debug screen tests, see Screen:redraw_debug().
@@ -454,7 +454,7 @@ end
--- screen:expect(grid, [attr_ids])
--- screen:expect(condition)
--- or keyword args (supports more options):
---- screen:expect{grid=[[...]], cmdline={...}, condition=function() ... end}
+--- screen:expect({ grid=[[...]], cmdline={...}, condition=function() ... end })
---
--- @param expected string|function|test.function.ui.screen.Expect
--- @param attr_ids? table<integer,table<string,any>>
@@ -1713,21 +1713,24 @@ function Screen:_print_snapshot()
end
end
local fn_name = modify_attrs and 'add_extra_attr_ids' or 'set_default_attr_ids'
- attrstr = ('screen:' .. fn_name .. ' {\n' .. table.concat(attrstrs, '\n') .. '\n}\n\n')
+ attrstr = ('screen:' .. fn_name .. '({\n' .. table.concat(attrstrs, '\n') .. '\n})\n\n')
end
- local result = ('%sscreen:expect({\n grid = [[\n %s\n ]]'):format(
- attrstr,
- kwargs.grid:gsub('\n', '\n ')
- )
+ local extstr = ''
for _, k in ipairs(ext_keys) do
if ext_state[k] ~= nil and not (k == 'win_viewport' and not self.options.ext_multigrid) then
- result = result .. ', ' .. k .. '=' .. fmt_ext_state(k, ext_state[k])
+ extstr = extstr .. '\n ' .. k .. ' = ' .. fmt_ext_state(k, ext_state[k]) .. ','
end
end
- result = result .. '\n})'
- return result
+ return ('%sscreen:expect(%s%s%s%s%s'):format(
+ attrstr,
+ #extstr > 0 and '{\n grid = [[\n ' or '[[\n',
+ #extstr > 0 and kwargs.grid:gsub('\n', '\n ') or kwargs.grid,
+ #extstr > 0 and '\n ]],' or '\n]]',
+ extstr,
+ #extstr > 0 and '\n})' or ')'
+ )
end
function Screen:print_snapshot()