neovim/test/functional/ui/tabline_spec.lua

58 lines
1.5 KiB
Lua
Raw Normal View History

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