tabline_spec.lua 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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
  7. before_each(function()
  8. clear()
  9. screen = Screen.new(25, 5)
  10. screen:attach({rgb=true, ext_tabline=true})
  11. screen:set_on_event_handler(function(name, data)
  12. if name == "tabline_update" then
  13. event_curtab, event_tabs = unpack(data)
  14. end
  15. end)
  16. end)
  17. after_each(function()
  18. screen:detach()
  19. end)
  20. it('publishes UI events', function()
  21. command("tabedit another-tab")
  22. local expected_tabs = {
  23. {tab = { id = 1 }, name = '[No Name]'},
  24. {tab = { id = 2 }, name = 'another-tab'},
  25. }
  26. screen:expect{grid=[[
  27. ^ |
  28. ~ |
  29. ~ |
  30. ~ |
  31. |
  32. ]], condition=function()
  33. eq({ id = 2 }, event_curtab)
  34. eq(expected_tabs, event_tabs)
  35. end}
  36. command("tabNext")
  37. screen:expect{grid=[[
  38. ^ |
  39. ~ |
  40. ~ |
  41. ~ |
  42. |
  43. ]], condition=function()
  44. eq({ id = 1 }, event_curtab)
  45. eq(expected_tabs, event_tabs)
  46. end}
  47. end)
  48. end)