Files
neovim/test/functional/ui/tabline_spec.lua
Björn Linse 4987311fb5 tests/ui: remove unnecessary screen:detach()
It is perfectly fine and expected to detach from the screen just by
the UI disconnecting from nvim or exiting nvim. Just keep detach() in
screen_basic_spec, to get some coverage of the detach method itself.

This avoids hang on failure in many situations (though one could argue
that detach() should be "fast", or at least "as fast as resize",
which works in press-return already).

Never use detach() just to change the size of the screen, try_resize()
method exists for that specifically.
2019-10-13 22:10:42 +02:00

51 lines
1.4 KiB
Lua

local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, command, eq = helpers.clear, helpers.command, helpers.eq
describe('ui/ext_tabline', function()
local screen
local event_tabs, event_curtab
before_each(function()
clear()
screen = Screen.new(25, 5)
screen:attach({rgb=true, ext_tabline=true})
screen:set_on_event_handler(function(name, data)
if name == "tabline_update" then
event_curtab, event_tabs = unpack(data)
end
end)
end)
it('publishes UI events', function()
command("tabedit another-tab")
local expected_tabs = {
{tab = { id = 1 }, name = '[No Name]'},
{tab = { id = 2 }, name = 'another-tab'},
}
screen:expect{grid=[[
^ |
~ |
~ |
~ |
|
]], condition=function()
eq({ id = 2 }, event_curtab)
eq(expected_tabs, event_tabs)
end}
command("tabNext")
screen:expect{grid=[[
^ |
~ |
~ |
~ |
|
]], condition=function()
eq({ id = 1 }, event_curtab)
eq(expected_tabs, event_tabs)
end}
end)
end)