refactor: format test/*

This commit is contained in:
Justin M. Keyes
2024-01-03 02:09:18 +01:00
parent 59d117ec99
commit 04f2f864e2
363 changed files with 30631 additions and 20833 deletions

View File

@@ -16,7 +16,7 @@ describe('vim.ui', function()
describe('select()', function()
it('can select an item', function()
local result = exec_lua[[
local result = exec_lua [[
local items = {
{ name = 'Item 1' },
{ name = 'Item 2' },
@@ -51,7 +51,7 @@ describe('vim.ui', function()
describe('input()', function()
it('can input text', function()
local result = exec_lua[[
local result = exec_lua [[
local opts = {
prompt = 'Input: ',
}
@@ -117,38 +117,44 @@ describe('vim.ui', function()
it('can return nil when interrupted with Ctrl-C #18144', function()
feed(':lua result = "on_confirm not called"<cr>')
feed(':lua vim.ui.input({}, function(input) result = input end)<cr>')
poke_eventloop() -- This is needed because Ctrl-C flushes input
poke_eventloop() -- This is needed because Ctrl-C flushes input
feed('Inputted Text<c-c>')
eq(true, exec_lua('return (nil == result)'))
end)
it('can return the identical object when an arbitrary opts.cancelreturn object is given', function()
feed(':lua fn = function() return 42 end<CR>')
eq(42, exec_lua('return fn()'))
feed(':lua vim.ui.input({ cancelreturn = fn }, function(input) result = input end)<cr>')
feed('cancel<esc>')
eq(true, exec_lua('return (result == fn)'))
eq(42, exec_lua('return result()'))
end)
it(
'can return the identical object when an arbitrary opts.cancelreturn object is given',
function()
feed(':lua fn = function() return 42 end<CR>')
eq(42, exec_lua('return fn()'))
feed(':lua vim.ui.input({ cancelreturn = fn }, function(input) result = input end)<cr>')
feed('cancel<esc>')
eq(true, exec_lua('return (result == fn)'))
eq(42, exec_lua('return result()'))
end
)
end)
describe('open()', function()
it('validation', function()
if is_os('win') or not is_ci('github') then
exec_lua[[vim.system = function() return { wait=function() return { code=3} end } end]]
exec_lua [[vim.system = function() return { wait=function() return { code=3} end } end]]
end
if not is_os('bsd') then
matches('vim.ui.open: command failed %(%d%): { "[^"]+", .*"non%-existent%-file" }',
exec_lua[[local _, err = vim.ui.open('non-existent-file') ; return err]])
matches(
'vim.ui.open: command failed %(%d%): { "[^"]+", .*"non%-existent%-file" }',
exec_lua [[local _, err = vim.ui.open('non-existent-file') ; return err]]
)
end
exec_lua[[
exec_lua [[
vim.fn.has = function() return 0 end
vim.fn.executable = function() return 0 end
]]
eq('vim.ui.open: no handler found (tried: wslview, xdg-open)',
exec_lua[[local _, err = vim.ui.open('foo') ; return err]])
eq(
'vim.ui.open: no handler found (tried: wslview, xdg-open)',
exec_lua [[local _, err = vim.ui.open('foo') ; return err]]
)
end)
end)
end)