focus_spec.lua 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local thelpers = require('test.functional.terminal.helpers')
  3. local lfs = require('lfs')
  4. local clear = helpers.clear
  5. local nvim_prog = helpers.nvim_prog
  6. local feed_command = helpers.feed_command
  7. local feed_data = thelpers.feed_data
  8. if helpers.pending_win32(pending) then return end
  9. describe('autoread TUI FocusGained/FocusLost', function()
  10. local f1 = 'xtest-foo'
  11. local screen
  12. before_each(function()
  13. clear()
  14. screen = thelpers.screen_setup(0, '["'..nvim_prog
  15. ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]')
  16. end)
  17. teardown(function()
  18. os.remove(f1)
  19. end)
  20. it('external file change', function()
  21. local path = f1
  22. local expected_addition = [[
  23. line 1
  24. line 2
  25. line 3
  26. line 4
  27. ]]
  28. helpers.write_file(path, '')
  29. lfs.touch(path, os.time() - 10)
  30. feed_command('edit '..path)
  31. feed_data('\027[O')
  32. screen:expect{grid=[[
  33. {1: } |
  34. {4:~ }|
  35. {4:~ }|
  36. {4:~ }|
  37. {5:xtest-foo }|
  38. :edit xtest-foo |
  39. {3:-- TERMINAL --} |
  40. ]]}
  41. helpers.write_file(path, expected_addition)
  42. feed_data('\027[I')
  43. screen:expect{grid=[[
  44. {1:l}ine 1 |
  45. line 2 |
  46. line 3 |
  47. line 4 |
  48. {5:xtest-foo }|
  49. "xtest-foo" 4L, 28B |
  50. {3:-- TERMINAL --} |
  51. ]]}
  52. end)
  53. end)