tabline_spec.lua 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local Screen = require('test.functional.ui.screen')
  3. local clear, command, eq = helpers.clear, helpers.command, helpers.eq
  4. describe('ui/ext_tabline', function()
  5. local screen
  6. local event_tabs, event_curtab, event_curbuf, event_buffers
  7. before_each(function()
  8. clear()
  9. screen = Screen.new(25, 5)
  10. screen:attach({rgb=true, ext_tabline=true})
  11. function screen:_handle_tabline_update(curtab, tabs, curbuf, buffers)
  12. event_curtab = curtab
  13. event_tabs = tabs
  14. event_curbuf = curbuf
  15. event_buffers = buffers
  16. end
  17. end)
  18. it('publishes UI events', function()
  19. command("tabedit another-tab")
  20. local expected_tabs = {
  21. {tab = { id = 1 }, name = '[No Name]'},
  22. {tab = { id = 2 }, name = 'another-tab'},
  23. }
  24. screen:expect{grid=[[
  25. ^ |
  26. ~ |
  27. ~ |
  28. ~ |
  29. |
  30. ]], condition=function()
  31. eq({ id = 2 }, event_curtab)
  32. eq(expected_tabs, event_tabs)
  33. end}
  34. command("tabNext")
  35. screen:expect{grid=[[
  36. ^ |
  37. ~ |
  38. ~ |
  39. ~ |
  40. |
  41. ]], condition=function()
  42. eq({ id = 1 }, event_curtab)
  43. eq(expected_tabs, event_tabs)
  44. end}
  45. end)
  46. it('buffer UI events', function()
  47. local expected_buffers_initial= {
  48. {buffer = { id = 1 }, name = '[No Name]'},
  49. }
  50. screen:expect{grid=[[
  51. ^ |
  52. ~ |
  53. ~ |
  54. ~ |
  55. |
  56. ]], condition=function()
  57. eq({ id = 1}, event_curbuf)
  58. eq(expected_buffers_initial, event_buffers)
  59. end}
  60. command("badd another-buffer")
  61. command("bnext")
  62. local expected_buffers = {
  63. {buffer = { id = 2 }, name = 'another-buffer'},
  64. }
  65. screen:expect{grid=[[
  66. ^ |
  67. ~ |
  68. ~ |
  69. ~ |
  70. |
  71. ]], condition=function()
  72. eq({ id = 2 }, event_curbuf)
  73. eq(expected_buffers, event_buffers)
  74. end}
  75. end)
  76. end)