Last active
November 10, 2015 14:15
-
-
Save mhinz/d6608f9c922bfa84cc95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local Helpers = require('test.functional.helpers') | |
| local Screen = require('test.functional.ui.screen') | |
| local buf = Helpers.curbufmeths | |
| local command = Helpers.command | |
| local eq = Helpers.eq | |
| local execute = Helpers.execute | |
| local feed = Helpers.feed | |
| local nvim = Helpers.nvim | |
| local nvim_prog = Helpers.nvim_prog | |
| local set_session = Helpers.set_session | |
| local spawn = Helpers.spawn | |
| local shada_file = 'test.shada' | |
| -- Helpers.clear() uses "-i NONE", which is not useful for this test. | |
| local function clear() | |
| if session then | |
| session:exit(0) | |
| end | |
| set_session(spawn({nvim_prog, | |
| '-u', 'NONE', | |
| '--cmd', 'set noswapfile undodir=. directory=. viewdir=. backupdir=.', | |
| '--embed'})) | |
| end | |
| describe(':oldfiles', function() | |
| before_each(clear) | |
| after_each(function() | |
| os.remove(shada_file) | |
| end) | |
| it('shows most recently used files', function() | |
| screen = Screen.new(50, 5) | |
| screen:attach() | |
| execute('edit testfile1') | |
| local filename1 = buf.get_name() | |
| execute('edit testfile2') | |
| local filename2 = buf.get_name() | |
| execute('wshada ' .. shada_file) | |
| execute('rshada! ' .. shada_file) | |
| execute('oldfiles') | |
| screen:expect([[ | |
| testfile2 | | |
| 1: ]].. filename1 ..[[ | | |
| 2: ]].. filename2 ..[[ | | |
| | | |
| Press ENTER or type command to continue^ | | |
| ]]) | |
| end) | |
| end) | |
| describe(':oldfiles!', function() | |
| local filename | |
| before_each(function() | |
| clear() | |
| execute('edit testfile1') | |
| execute('edit testfile2') | |
| filename = buf.get_name() | |
| execute('wshada ' .. shada_file) | |
| clear() | |
| execute('rshada! ' .. shada_file) | |
| execute('oldfiles!') | |
| end) | |
| after_each(function() | |
| os.remove(shada_file) | |
| end) | |
| it('provides a prompt and edits the chosen file', function() | |
| feed('2<cr>') | |
| eq(filename, buf.get_name()) | |
| end) | |
| it('provides a prompt and does nothing on <cr>', function() | |
| feed('<cr>') | |
| eq('', buf.get_name()) | |
| end) | |
| it('provides a prompt and does nothing if choice is out-of-bounds', function() | |
| feed('3<cr>') | |
| eq('', buf.get_name()) | |
| end) | |
| end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment