From 04f2f864e270e772c6326cefdf24947f0130e492 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 3 Jan 2024 02:09:18 +0100 Subject: refactor: format test/* --- test/functional/lua/ui_spec.lua | 42 +++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'test/functional/lua/ui_spec.lua') diff --git a/test/functional/lua/ui_spec.lua b/test/functional/lua/ui_spec.lua index d4c150c5f2..b3057068fe 100644 --- a/test/functional/lua/ui_spec.lua +++ b/test/functional/lua/ui_spec.lua @@ -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"') feed(':lua vim.ui.input({}, function(input) result = input end)') - poke_eventloop() -- This is needed because Ctrl-C flushes input + poke_eventloop() -- This is needed because Ctrl-C flushes input feed('Inputted Text') 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') - eq(42, exec_lua('return fn()')) - feed(':lua vim.ui.input({ cancelreturn = fn }, function(input) result = input end)') - feed('cancel') - 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') + eq(42, exec_lua('return fn()')) + feed(':lua vim.ui.input({ cancelreturn = fn }, function(input) result = input end)') + feed('cancel') + 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) -- cgit