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
|
|
|
|
2017-04-24 17:17:15 -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)
|
2017-04-25 01:14:29 -07:00
|
|
|
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)
|
|
|
|
|
2017-04-24 17:17:15 -07:00
|
|
|
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()
|
2017-04-27 22:01:46 -07:00
|
|
|
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()
|
2017-04-27 22:01:46 -07:00
|
|
|
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)
|