diff options
Diffstat (limited to 'test/functional/ex_cmds/oldfiles_spec.lua')
-rw-r--r-- | test/functional/ex_cmds/oldfiles_spec.lua | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua index 19611429e0..8d1469f343 100644 --- a/test/functional/ex_cmds/oldfiles_spec.lua +++ b/test/functional/ex_cmds/oldfiles_spec.lua @@ -4,7 +4,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear local command = helpers.command local expect_exit = helpers.expect_exit -local buf, eq, feed_command = helpers.curbufmeths, helpers.eq, helpers.feed_command +local api, eq, feed_command = helpers.api, helpers.eq, helpers.feed_command local feed, poke_eventloop = helpers.feed, helpers.poke_eventloop local ok = helpers.ok local eval = helpers.eval @@ -12,9 +12,15 @@ local eval = helpers.eval local shada_file = 'Xtest.shada' local function _clear() - clear{args={'-i', shada_file, -- Need shada for these tests. - '--cmd', 'set noswapfile undodir=. directory=. viewdir=. backupdir=. belloff= noshowcmd noruler'}, - args_rm={'-i', '--cmd'}} + clear { + args = { + '-i', + shada_file, -- Need shada for these tests. + '--cmd', + 'set noswapfile undodir=. directory=. viewdir=. backupdir=. belloff= noshowcmd noruler', + }, + args_rm = { '-i', '--cmd' }, + } end describe(':oldfiles', function() @@ -36,12 +42,12 @@ describe(':oldfiles', function() feed_command('edit testfile2') feed_command('wshada') feed_command('rshada!') - local oldfiles = helpers.meths.get_vvar('oldfiles') + local oldfiles = api.nvim_get_vvar('oldfiles') feed_command('oldfiles') screen:expect([[ | - 1: ]].. add_padding(oldfiles[1]) ..[[ | - 2: ]].. add_padding(oldfiles[2]) ..[[ | + 1: ]] .. add_padding(oldfiles[1]) .. [[ | + 2: ]] .. add_padding(oldfiles[2]) .. [[ | | Press ENTER or type command to continue^ | ]]) @@ -50,16 +56,16 @@ describe(':oldfiles', function() it('can be filtered with :filter', function() feed_command('edit file_one.txt') - local file1 = buf.get_name() + local file1 = api.nvim_buf_get_name(0) feed_command('edit file_two.txt') - local file2 = buf.get_name() + local file2 = api.nvim_buf_get_name(0) feed_command('edit another.txt') - local another = buf.get_name() + local another = api.nvim_buf_get_name(0) feed_command('wshada') feed_command('rshada!') local function get_oldfiles(cmd) - local t = eval([[split(execute(']]..cmd..[['), "\n")]]) + local t = eval([[split(execute(']] .. cmd .. [['), "\n")]]) for i, _ in ipairs(t) do t[i] = t[i]:gsub('^%d+:%s+', '') end @@ -68,16 +74,16 @@ describe(':oldfiles', function() end local oldfiles = get_oldfiles('oldfiles') - eq({another, file1, file2}, oldfiles) + eq({ another, file1, file2 }, oldfiles) oldfiles = get_oldfiles('filter file_ oldfiles') - eq({file1, file2}, oldfiles) + eq({ file1, file2 }, oldfiles) oldfiles = get_oldfiles('filter /another/ oldfiles') - eq({another}, oldfiles) + eq({ another }, oldfiles) oldfiles = get_oldfiles('filter! file_ oldfiles') - eq({another}, oldfiles) + eq({ another }, oldfiles) end) end) @@ -89,9 +95,9 @@ describe(':browse oldfiles', function() before_each(function() _clear() feed_command('edit testfile1') - filename = buf.get_name() + filename = api.nvim_buf_get_name(0) feed_command('edit testfile2') - filename2 = buf.get_name() + filename2 = api.nvim_buf_get_name(0) feed_command('wshada') poke_eventloop() _clear() @@ -102,7 +108,7 @@ describe(':browse oldfiles', function() -- Ensure v:oldfiles isn't busted. Since things happen so fast, -- the ordering of v:oldfiles is unstable (it uses qsort() under-the-hood). -- Let's verify the contents and the length of v:oldfiles before moving on. - oldfiles = helpers.meths.get_vvar('oldfiles') + oldfiles = helpers.api.nvim_get_vvar('oldfiles') eq(2, #oldfiles) ok(filename == oldfiles[1] or filename == oldfiles[2]) ok(filename2 == oldfiles[1] or filename2 == oldfiles[2]) @@ -117,16 +123,16 @@ describe(':browse oldfiles', function() it('provides a prompt and edits the chosen file', function() feed('2<cr>') - eq(oldfiles[2], buf.get_name()) + eq(oldfiles[2], api.nvim_buf_get_name(0)) end) it('provides a prompt and does nothing on <cr>', function() feed('<cr>') - eq('', buf.get_name()) + eq('', api.nvim_buf_get_name(0)) end) it('provides a prompt and does nothing if choice is out-of-bounds', function() feed('3<cr>') - eq('', buf.get_name()) + eq('', api.nvim_buf_get_name(0)) end) end) |