diff options
author | luukvbaal <luukvbaal@gmail.com> | 2024-12-04 16:31:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-04 07:31:08 -0800 |
commit | e2a91876ac61b4265e62a73ea9aed37597976b85 (patch) | |
tree | 9d02c36da3206312cdb80a3da71d1595d7046996 | |
parent | 6551e3063043b86acc90476297645150bd198c3a (diff) | |
download | rneovim-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"
| } },
| })
-rw-r--r-- | test/functional/treesitter/highlight_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 25 |
2 files changed, 16 insertions, 13 deletions
diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua index f2563d9bad..028c01f14a 100644 --- a/test/functional/treesitter/highlight_spec.lua +++ b/test/functional/treesitter/highlight_spec.lua @@ -404,7 +404,7 @@ describe('treesitter highlighting (C)', function() ]], }) - feed 'u' + feed 'u:<esc>' screen:expect({ grid = [[ @@ -425,7 +425,7 @@ describe('treesitter highlighting (C)', function() } | } | ^} | - 19 changes; before #2 0 seconds ago | + | ]], }) end) 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() |