tests: add more tests (#439)

* tests: add more tests

* fix: for now comment out tabline tests

will check later why some are passing locally but not in CI
This commit is contained in:
Shadman 2021-11-22 19:40:18 +06:00 committed by GitHub
parent 3ad39d4d76
commit f286f0443d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 648 additions and 5 deletions

View File

@ -267,7 +267,8 @@ local function set_statusline()
if next(config.sections) ~= nil or next(config.inactive_sections) ~= nil then if next(config.sections) ~= nil or next(config.inactive_sections) ~= nil then
vim.cmd 'autocmd lualine VimResized * redrawstatus' vim.cmd 'autocmd lualine VimResized * redrawstatus'
else else
vim.go.statusline = nil vim.go.statusline = ''
vim.go.laststatus = 0
end end
end end

View File

@ -49,7 +49,11 @@ local function apply_configuration(config_table)
return vim.deepcopy(config) return vim.deepcopy(config)
end end
local function parse_sections(section_group_name) local function parse_sections(section_group_name)
if not config_table[section_group_name] then if config_table[section_group_name] == nil then
return
end
if not next(config_table[section_group_name]) then
config[section_group_name] = {}
return return
end end
for section_name, section in pairs(config_table[section_group_name]) do for section_name, section in pairs(config_table[section_group_name]) do

View File

@ -11,9 +11,7 @@ M.meths = setmetatable({}, {
end, end,
}) })
-- Checks ouput of a component function M.init_component(component, opts)
M.assert_component = function(component, opts, result)
-- for testing global options
if component == nil then if component == nil then
component = 'special.function_component' component = 'special.function_component'
else else
@ -26,9 +24,19 @@ M.assert_component = function(component, opts, result)
opts[1] = comp opts[1] = comp
comp = require 'lualine.components.special.function_component'(opts) comp = require 'lualine.components.special.function_component'(opts)
end end
return comp
end
-- Checks ouput of a component
M.assert_component = function(component, opts, result)
local comp = M.init_component(component, opts)
-- for testing global options
eq(result, comp:draw(opts.hl)) eq(result, comp:draw(opts.hl))
end end
function M.assert_component_instence(comp, result)
eq(result, comp:draw(comp.options.hl))
end
-- sets defaults for component options -- sets defaults for component options
M.build_component_opts = function(opts) M.build_component_opts = function(opts)
if not opts then if not opts then

View File

@ -6,6 +6,7 @@ if os.getenv 'TEST_COV' then
end end
-- load lualine and plenary -- load lualine and plenary
vim.cmd [[ vim.cmd [[
set noswapfile
set rtp+=. set rtp+=.
set rtp+=../plenary.nvim set rtp+=../plenary.nvim
set rtp+=../nvim-web-devicons/ set rtp+=../nvim-web-devicons/

View File

@ -216,6 +216,7 @@ describe('Encoding component', function()
tmp_fp:close() tmp_fp:close()
vim.cmd('e ' .. tmp_path) vim.cmd('e ' .. tmp_path)
assert_component('encoding', opts, 'utf-8') assert_component('encoding', opts, 'utf-8')
vim.cmd('bd!')
os.remove(tmp_path) os.remove(tmp_path)
end) end)
end) end)
@ -387,3 +388,216 @@ describe('Mode component', function()
vim.api.nvim_get_mode:revert() vim.api.nvim_get_mode:revert()
end) end)
end) end)
describe('FileSize component', function()
it('works', function()
local opts = build_component_opts {
component_separators = { left = '', right = '' },
padding = 0,
}
local fname = 'test-file.txt'
local f = io.open(fname, 'w')
f:write(string.rep('........................................\n', 200))
f:close()
vim.cmd(':edit ' .. fname)
assert_component('filesize', opts, '8.0k')
vim.cmd ':bdelete!'
os.remove(fname)
end)
end)
describe('Filename component', function()
local function shorten_path(path, target)
target = target and target or 40
local sep = package.config:sub(1, 1)
local winwidth = vim.fn.winwidth(0)
local segments = select(2, string.gsub(path, sep, ''))
for _ = 0, segments do
if winwidth <= 84 or #path > winwidth - target then
path = path:gsub(string.format('([^%s])[^%s]+%%%s', sep, sep, sep), '%1' .. sep, 1)
end
end
return path
end
it('works', function()
local opts = build_component_opts {
component_separators = { left = '', right = '' },
padding = 0,
file_status = false,
path = 0,
}
vim.cmd ':e test-file.txt'
assert_component('filename', opts, 'test-file.txt')
vim.cmd ':bdelete!'
end)
it('can show file_status', function()
local opts = build_component_opts {
component_separators = { left = '', right = '' },
padding = 0,
file_status = true,
path = 0,
}
vim.cmd ':e test-file.txt'
vim.bo.modified = false
assert_component('filename', opts, 'test-file.txt')
vim.bo.modified = true
assert_component('filename', opts, 'test-file.txt[+]')
vim.bo.modified = false
vim.bo.ro = true
assert_component('filename', opts, 'test-file.txt[-]')
vim.cmd ':bdelete!'
end)
it('can show relative path', function()
local opts = build_component_opts {
component_separators = { left = '', right = '' },
padding = 0,
file_status = false,
path = 1,
}
vim.cmd ':e test-file.txt'
assert_component('filename', opts, shorten_path(vim.fn.expand '%:~:.'))
vim.cmd ':bdelete!'
end)
it('can show full path', function()
local opts = build_component_opts {
component_separators = { left = '', right = '' },
padding = 0,
file_status = false,
path = 2,
}
vim.cmd ':e test-file.txt'
assert_component('filename', opts, shorten_path(vim.fn.expand '%:p'))
vim.cmd ':bdelete!'
end)
end)
describe('vim option & variable component', function()
local opts = build_component_opts {
component_separators = { left = '', right = '' },
padding = 0,
}
local function assert_vim_var_component(name, options, result)
options[1] = name
assert_component('special.vim_var_component', options, result)
opts[1] = nil
end
it('works with variable', function()
assert_vim_var_component('g:gvar', opts, '')
vim.g.gvar = 'var1'
assert_vim_var_component('g:gvar', opts, 'var1')
vim.g.gvar = 'var2'
assert_vim_var_component('g:gvar', opts, 'var2')
vim.b.gvar = 'bvar1'
assert_vim_var_component('b:gvar', opts, 'bvar1')
vim.w.gvar = 'wvar1'
assert_vim_var_component('w:gvar', opts, 'wvar1')
end)
it('can index dictionaries', function()
vim.g.gvar = { a = { b = 'var-value' } }
assert_vim_var_component('g:gvar.a.b', opts, 'var-value')
end)
it('works with options', function()
local old_number = vim.wo.number
vim.wo.number = false
assert_vim_var_component('wo:number', opts, 'false')
vim.wo.number = old_number
local old_tw = vim.go.tw
vim.go.tw = 80
assert_vim_var_component('go:tw', opts, '80')
vim.go.tw = old_tw
end)
end)
describe('Vim option & variable component', function()
local opts = build_component_opts {
component_separators = { left = '', right = '' },
padding = 0,
}
local function assert_vim_var_component(name, options, result)
options[1] = name
assert_component('special.eval_func_component', options, result)
opts[1] = nil
end
it('works with vim function', function()
vim.cmd [[
func! TestFunction() abort
return "TestVimFunction"
endf
]]
assert_vim_var_component('TestFunction', opts, 'TestVimFunction')
vim.cmd 'delfunction TestFunction'
end)
it('works with lua expression', function()
_G.TestFunction = function()
return 'TestLuaFunction'
end
assert_vim_var_component('TestFunction()', opts, 'TestLuaFunction')
_G.TestFunction = nil
end)
end)
describe('Branch component', function()
local tmpdir
local file
local git = function(...)
return vim.fn.system('git -C ' .. tmpdir .. ' ' .. string.format(...))
end
local assert_comp_ins = helpers.assert_component_instence
before_each(function()
tmpdir = os.tmpname()
os.remove(tmpdir)
file = tmpdir .. '/test.txt'
vim.fn.mkdir(tmpdir, 'p')
git 'init -b test_branch'
vim.cmd [[aug lualine
au!
aug END
]]
end)
after_each(function()
os.remove(tmpdir)
end)
it('works with regular branches', function()
local opts = build_component_opts {
component_separators = { left = '', right = '' },
padding = 0,
}
local branch_comp = helpers.init_component('branch', opts)
vim.cmd('e ' .. file)
assert_comp_ins(branch_comp, ' test_branch')
git 'checkout -b test_branch2'
vim.cmd 'e k'
vim.cmd 'bd'
vim.cmd('e ' .. file)
opts.icons_enabled = false
assert_comp_ins(branch_comp, 'test_branch2')
end)
-- TODO: Figure out why this test fails in CI
-- it('works in detached head mode', function()
-- local opts = build_component_opts {
-- component_separators = { left = '', right = '' },
-- icons_enabled = false,
-- padding = 0,
-- }
-- git 'checkout -b test_branch2'
-- git 'commit --allow-empty -m "test commit1"'
-- git 'commit --allow-empty -m "test commit2"'
-- git 'commit --allow-empty -m "test commit3"'
-- git('checkout HEAD~1')
-- vim.cmd('e ' .. file)
-- local rev = git('rev-parse --short=6 HEAD'):sub(1, 6)
-- assert_component('branch', opts, rev)
-- end)
end)

View File

@ -0,0 +1,415 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
local eq = assert.are.same
describe('Lualine', function()
local utils = require 'lualine.utils.utils'
local lualine_focused = true
utils.is_focused = function()
return lualine_focused
end
local config = {
options = {
icons_enabled = true,
theme = 'gruvbox',
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
disabled_filetypes = {},
always_divide_middle = true,
},
sections = {
lualine_a = { 'mode' },
-- We can't test branch component inside lualines repo.
-- As branch name will differ in pr/CI. We could setup a dummy repo
-- but plenary doesn't yet support setup() & teardown() so replacing
-- branch with a dummy component.
lualine_b = {
{
function()
return 'master'
end,
icon = '',
},
{
'diagnostics',
sources = { 'nvim_lsp', 'coc' },
},
},
lualine_c = { 'filename' },
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'progress' },
lualine_z = { 'location' },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { 'filename' },
lualine_x = { 'location' },
lualine_y = {},
lualine_z = {},
},
tabline = {},
extensions = {},
}
before_each(function()
vim.cmd 'bufdo bdelete'
pcall(vim.cmd, 'tabdo tabclose')
lualine_focused = true
require('lualine').setup(config)
end)
it('shows active statusline', function()
eq(
'%#lualine_a_normal# NORMAL %#lualine_transitional_lualine_a_normal_to_lualine_b_normal#%#lualine_b_normal#  master %#lualine_transitional_lualine_b_normal_to_lualine_c_normal#%<%#lualine_c_normal# [No Name] %#lualine_c_normal#%=%#lualine_c_normal#  %#lualine_transitional_lualine_b_normal_to_lualine_c_normal#%#lualine_b_normal# %3p%% %#lualine_transitional_lualine_a_normal_to_lualine_b_normal#%#lualine_a_normal# %3l:%-2v ',
require('lualine').statusline()
)
end)
it('shows inactive statusline', function()
lualine_focused = false
eq(
'%<%#lualine_c_inactive# [No Name] %#lualine_c_inactive#%=%#lualine_c_inactive# %3l:%-2v ',
require('lualine').statusline()
)
end)
it('get_config can retrive config', function()
eq(config, require('lualine').get_config())
end)
it('can live update config', function()
local conf = require('lualine').get_config()
conf.sections.lualine_a = {}
require('lualine').setup(conf)
eq(
'%#lualine_b_normal#  master %#lualine_transitional_lualine_b_normal_to_lualine_c_normal#%<%#lualine_c_normal# [No Name] %#lualine_c_normal#%=%#lualine_c_normal#  %#lualine_transitional_lualine_b_normal_to_lualine_c_normal#%#lualine_b_normal# %3p%% %#lualine_transitional_lualine_a_normal_to_lualine_b_normal#%#lualine_a_normal# %3l:%-2v ',
require('lualine').statusline()
)
end)
it('Can work without section separators', function()
local conf = vim.deepcopy(config)
conf.options.section_separators = ''
require('lualine').setup(conf)
eq(
'%#lualine_a_normal# NORMAL %#lualine_b_normal#  master %<%#lualine_c_normal# [No Name] %#lualine_c_normal#%=%#lualine_c_normal#  %#lualine_b_normal# %3p%% %#lualine_a_normal# %3l:%-2v ',
require('lualine').statusline()
)
end)
it('Can work without component_separators', function()
local conf = vim.deepcopy(config)
table.insert(conf.sections.lualine_a, function()
return 'test_comp1'
end)
table.insert(conf.sections.lualine_z, function()
return 'test_comp2'
end)
require('lualine').setup(conf)
eq(
'%#lualine_a_normal# NORMAL %#lualine_a_normal# test_comp1 %#lualine_transitional_lualine_a_normal_to_lualine_b_normal#%#lualine_b_normal#  master %#lualine_transitional_lualine_b_normal_to_lualine_c_normal#%<%#lualine_c_normal# [No Name] %#lualine_c_normal#%=%#lualine_c_normal#  %#lualine_transitional_lualine_b_normal_to_lualine_c_normal#%#lualine_b_normal# %3p%% %#lualine_transitional_lualine_a_normal_to_lualine_b_normal#%#lualine_a_normal# %3l:%-2v %#lualine_a_normal# test_comp2 ',
require('lualine').statusline()
)
conf.options.component_separators = ''
require('lualine').setup(conf)
eq(
'%#lualine_a_normal# NORMAL %#lualine_a_normal# test_comp1 %#lualine_transitional_lualine_a_normal_to_lualine_b_normal#%#lualine_b_normal#  master %#lualine_transitional_lualine_b_normal_to_lualine_c_normal#%<%#lualine_c_normal# [No Name] %#lualine_c_normal#%=%#lualine_c_normal#  %#lualine_transitional_lualine_b_normal_to_lualine_c_normal#%#lualine_b_normal# %3p%% %#lualine_transitional_lualine_a_normal_to_lualine_b_normal#%#lualine_a_normal# %3l:%-2v %#lualine_a_normal# test_comp2 ',
require('lualine').statusline()
)
end)
it('mid divider can be disbled on special case', function()
local conf = vim.deepcopy(config)
conf.options.always_divide_middle = false
conf.sections.lualine_x = {}
conf.sections.lualine_y = {}
conf.sections.lualine_z = {}
require('lualine').setup(conf)
eq(
'%#lualine_a_normal# NORMAL %#lualine_transitional_lualine_a_normal_to_lualine_b_normal#%#lualine_b_normal#  master %#lualine_transitional_lualine_b_normal_to_lualine_c_normal#%<%#lualine_c_normal# [No Name] ',
require('lualine').statusline(true)
)
end)
it('works with icons diabled', function()
local conf = vim.deepcopy(config)
conf.options.icons_enabled = false
conf.options.section_separators = ''
require('lualine').setup(conf)
eq(
'%#lualine_a_normal# NORMAL %#lualine_b_normal# master %<%#lualine_c_normal# [No Name] %#lualine_c_normal#%=%#lualine_c_normal# unix %#lualine_b_normal# %3p%% %#lualine_a_normal# %3l:%-2v ',
require('lualine').statusline(true)
)
end)
it('can be desabled for specific filetypes', function()
local conf = vim.deepcopy(config)
conf.options.disabled_filetypes = { 'test_ft' }
require('lualine').setup(conf)
local old_ft = vim.bo.ft
vim.bo.ft = 'test_ft'
eq('', require('lualine').statusline(true))
vim.bo.ft = old_ft
end)
it('can apply custom extensions', function()
local conf = vim.deepcopy(config)
table.insert(conf.extensions, {
filetypes = { 'test_ft' },
sections = {
lualine_a = {
function()
return 'custom_extension_component'
end,
},
},
})
local old_ft = vim.bo.ft
vim.bo.ft = 'test_ft'
require('lualine').setup(conf)
eq(
'%#lualine_a_normal# custom_extension_component %#lualine_transitional_lualine_a_normal_to_lualine_c_normal#%#lualine_c_normal#%=',
require('lualine').statusline(true)
)
vim.bo.ft = old_ft
end)
it('same extension can be applied to multiple filetypes', function()
local conf = vim.deepcopy(config)
table.insert(conf.extensions, {
filetypes = { 'test_ft1', 'test_ft2' },
sections = {
lualine_a = {
function()
return 'custom_extension_component'
end,
},
},
})
local old_ft = vim.bo.ft
vim.bo.ft = 'test_ft1'
require('lualine').setup(conf)
eq(
'%#lualine_a_normal# custom_extension_component %#lualine_transitional_lualine_a_normal_to_lualine_c_normal#%#lualine_c_normal#%=',
require('lualine').statusline()
)
vim.bo.ft = old_ft
eq(
'%#lualine_a_normal# NORMAL %#lualine_transitional_lualine_a_normal_to_lualine_b_normal#%#lualine_b_normal#  master %#lualine_transitional_lualine_b_normal_to_lualine_c_normal#%<%#lualine_c_normal# [No Name] %#lualine_c_normal#%=%#lualine_c_normal#  %#lualine_transitional_lualine_b_normal_to_lualine_c_normal#%#lualine_b_normal# %3p%% %#lualine_transitional_lualine_a_normal_to_lualine_b_normal#%#lualine_a_normal# %3l:%-2v ',
require('lualine').statusline()
)
vim.bo.ft = 'test_ft2'
eq(
'%#lualine_a_normal# custom_extension_component %#lualine_transitional_lualine_a_normal_to_lualine_c_normal#%#lualine_c_normal#%=',
require('lualine').statusline()
)
vim.bo.ft = old_ft
end)
-- TODO: figure put why some of the tablines tests fail in CI
-- describe('tabline', function()
-- local tab_conf = vim.deepcopy(config)
-- tab_conf.tabline = {
-- lualine_a = {
-- function()
-- return 'tabline_component'
-- end,
-- },
-- lualine_b = {},
-- lualine_c = {},
-- lualine_x = {},
-- lualine_y = {},
-- lualine_z = {},
-- }
--
-- it('can use tabline', function()
-- local conf = vim.deepcopy(tab_conf)
-- conf.tabline.lualine_a = {
-- function()
-- return 'tabline_component'
-- end,
-- }
-- require('lualine').setup(conf)
-- require('lualine').statusline()
-- eq(
-- '%#lualine_a_normal# tabline_component %#lualine_transitional_lualine_a_normal_to_lualine_c_normal#%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- end)
--
-- it('can use tabline as statusline', function()
-- local conf = vim.deepcopy(config)
-- conf.tabline = conf.sections
-- conf.sections = {}
-- conf.inactive_sections = {}
-- require('lualine').setup(conf)
-- require('lualine').statusline()
-- eq('', vim.go.statusline)
-- eq(
-- '%#lualine_a_normal# NORMAL %#lualine_transitional_lualine_a_normal_to_lualine_b_normal#%#lualine_b_normal#  master %#lualine_transitional_lualine_b_normal_to_lualine_c_normal#%<%#lualine_c_normal# [No Name] %#lualine_c_normal#%=%#lualine_c_normal#  %#lualine_transitional_lualine_b_normal_to_lualine_c_normal#%#lualine_b_normal# %3p%% %#lualine_transitional_lualine_a_normal_to_lualine_b_normal#%#lualine_a_normal# %3l:%-2v ',
-- require('lualine').tabline()
-- )
-- end)
-- describe('tabs component', function()
-- it('works', function()
-- local conf = vim.deepcopy(tab_conf)
-- conf.tabline.lualine_a = { { 'tabs', max_length = 1e3 } }
-- vim.cmd 'tabnew'
-- vim.cmd 'tabnew'
-- require('lualine').setup(conf)
-- require('lualine').statusline()
-- eq(
-- '%#lualine_tabs_active_0_no_mode#%1@LualineSwitchTab@ 1 %T%#lualine_tabs_active_0_no_mode#%2@LualineSwitchTab@ 2 %T%#lualine_transitional_lualine_tabs_active_0_no_mode_to_lualine_tabs_active_no_mode#%#lualine_tabs_active_no_mode#%3@LualineSwitchTab@ 3 %T%#lualine_transitional_lualine_tabs_active_no_mode_to_lualine_c_normal#%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- vim.cmd 'tabprev'
-- eq(
-- '%#lualine_tabs_active_0_no_mode#%1@LualineSwitchTab@ 1 %T%#lualine_transitional_lualine_tabs_active_0_no_mode_to_lualine_tabs_active_no_mode#%#lualine_tabs_active_no_mode#%2@LualineSwitchTab@ 2 %T%#lualine_transitional_lualine_tabs_active_no_mode_to_lualine_tabs_active_0_no_mode#%#lualine_tabs_active_0_no_mode#%3@LualineSwitchTab@ 3 %T%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- vim.cmd 'tabprev'
-- eq(
-- '%#lualine_tabs_active_no_mode#%1@LualineSwitchTab@ 1 %T%#lualine_transitional_lualine_tabs_active_no_mode_to_lualine_tabs_active_0_no_mode#%#lualine_tabs_active_0_no_mode#%2@LualineSwitchTab@ 2 %T%#lualine_tabs_active_0_no_mode#%3@LualineSwitchTab@ 3 %T%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- end)
-- it('mode option can change layout', function()
-- local conf = vim.deepcopy(tab_conf)
-- conf.tabline.lualine_a = { { 'tabs', max_length = 1e3, mode = 0 } }
-- vim.cmd('tabe ' .. 'a.txt')
-- vim.cmd('tabe ' .. 'b.txt')
-- require('lualine').setup(conf)
-- require('lualine').statusline()
-- eq(
-- '%#lualine_tabs_active_0_no_mode#%1@LualineSwitchTab@ 1 %T%#lualine_tabs_active_0_no_mode#%2@LualineSwitchTab@ 2 %T%#lualine_transitional_lualine_tabs_active_0_no_mode_to_lualine_tabs_active_no_mode#%#lualine_tabs_active_no_mode#%3@LualineSwitchTab@ 3 %T%#lualine_transitional_lualine_tabs_active_no_mode_to_lualine_c_normal#%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- conf.tabline.lualine_a = { { 'tabs', max_length = 1e3, mode = 1 } }
-- require('lualine').setup(conf)
-- require('lualine').statusline()
-- eq(
-- '%#lualine_tabs_active_0_no_mode#%1@LualineSwitchTab@ [No Name] %T%#lualine_tabs_active_0_no_mode#%2@LualineSwitchTab@ a.txt %T%#lualine_transitional_lualine_tabs_active_0_no_mode_to_lualine_tabs_active_no_mode#%#lualine_tabs_active_no_mode#%3@LualineSwitchTab@ b.txt %T%#lualine_transitional_lualine_tabs_active_no_mode_to_lualine_c_normal#%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- conf.tabline.lualine_a = { { 'tabs', max_length = 1e3, mode = 2 } }
-- require('lualine').setup(conf)
-- require('lualine').statusline()
-- eq(
-- '%#lualine_tabs_active_0_no_mode#%1@LualineSwitchTab@ 1 [No Name] %T%#lualine_tabs_active_0_no_mode#%2@LualineSwitchTab@ 2 a.txt %T%#lualine_transitional_lualine_tabs_active_0_no_mode_to_lualine_tabs_active_no_mode#%#lualine_tabs_active_no_mode#%3@LualineSwitchTab@ 3 b.txt %T%#lualine_transitional_lualine_tabs_active_no_mode_to_lualine_c_normal#%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- end)
-- end)
--
-- describe('buffers component', function()
-- it('works', function()
-- local conf = vim.deepcopy(tab_conf)
-- conf.tabline.lualine_a = { { 'buffers', max_length = 1e3, icons_enabled = false } }
-- vim.cmd('tabe ' .. 'a.txt')
-- vim.cmd('tabe ' .. 'b.txt')
-- require('lualine').setup(conf)
-- require('lualine').statusline()
-- eq(
-- '%#lualine_buffers_active_0_no_mode#%4@LualineSwitchBuffer@ a.txt %T%#lualine_transitional_lualine_buffers_active_0_no_mode_to_lualine_buffers_active_no_mode#%#lualine_buffers_active_no_mode#%5@LualineSwitchBuffer@ b.txt %T%#lualine_transitional_lualine_buffers_active_no_mode_to_lualine_buffers_active_0_no_mode#%#lualine_buffers_active_0_no_mode#%6@LualineSwitchBuffer@ [No Name] %T%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- vim.cmd 'tabprev'
-- eq(
-- '%#lualine_buffers_active_no_mode#%4@LualineSwitchBuffer@ a.txt %T%#lualine_transitional_lualine_buffers_active_no_mode_to_lualine_buffers_active_0_no_mode#%#lualine_buffers_active_0_no_mode#%5@LualineSwitchBuffer@ b.txt %T%#lualine_buffers_active_0_no_mode#%6@LualineSwitchBuffer@ [No Name] %T%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- vim.cmd 'tabprev'
-- eq(
-- '%#lualine_buffers_active_0_no_mode#%4@LualineSwitchBuffer@ a.txt %T%#lualine_buffers_active_0_no_mode#%5@LualineSwitchBuffer@ b.txt %T%#lualine_transitional_lualine_buffers_active_0_no_mode_to_lualine_buffers_active_no_mode#%#lualine_buffers_active_no_mode#%6@LualineSwitchBuffer@ [No Name] %T%#lualine_transitional_lualine_buffers_active_no_mode_to_lualine_c_normal#%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- end)
-- it('mode option can change layout', function()
-- local conf = vim.deepcopy(tab_conf)
-- conf.tabline.lualine_a = { { 'tabs', max_length = 1e3, mode = 0, icons_enabled = false } }
-- vim.cmd('tabe ' .. 'a.txt')
-- vim.cmd('tabe ' .. 'b.txt')
-- require('lualine').setup(conf)
-- require('lualine').statusline()
-- eq(
-- '%#lualine_tabs_active_0_no_mode#%1@LualineSwitchTab@ 1 %T%#lualine_tabs_active_0_no_mode#%2@LualineSwitchTab@ 2 %T%#lualine_transitional_lualine_tabs_active_0_no_mode_to_lualine_tabs_active_no_mode#%#lualine_tabs_active_no_mode#%3@LualineSwitchTab@ 3 %T%#lualine_transitional_lualine_tabs_active_no_mode_to_lualine_c_normal#%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- conf.tabline.lualine_a = { { 'buffers', max_length = 1e3, mode = 1, icons_enabled = false } }
-- require('lualine').setup(conf)
-- require('lualine').statusline()
-- eq(
-- '%#lualine_buffers_active_0_no_mode#%4@LualineSwitchBuffer@ 4 %T%#lualine_transitional_lualine_buffers_active_0_no_mode_to_lualine_buffers_active_no_mode#%#lualine_buffers_active_no_mode#%5@LualineSwitchBuffer@ 5 %T%#lualine_transitional_lualine_buffers_active_no_mode_to_lualine_buffers_active_0_no_mode#%#lualine_buffers_active_0_no_mode#%6@LualineSwitchBuffer@ 6 %T%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- conf.tabline.lualine_a = { { 'buffers', max_length = 1e3, mode = 2, icons_enabled = false } }
-- require('lualine').setup(conf)
-- require('lualine').statusline()
-- eq(
-- '%#lualine_buffers_active_0_no_mode#%4@LualineSwitchBuffer@ 4 a.txt %T%#lualine_transitional_lualine_buffers_active_0_no_mode_to_lualine_buffers_active_no_mode#%#lualine_buffers_active_no_mode#%5@LualineSwitchBuffer@ 5 b.txt %T%#lualine_transitional_lualine_buffers_active_no_mode_to_lualine_buffers_active_0_no_mode#%#lualine_buffers_active_0_no_mode#%6@LualineSwitchBuffer@ 6 [No Name] %T%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- end)
--
-- it('can show modified status', function()
-- local conf = vim.deepcopy(tab_conf)
-- conf.tabline.lualine_a = { { 'buffers', max_length = 1e3, show_modified_status = true, icons_enabled = false } }
-- require('lualine').setup(conf)
-- require('lualine').statusline()
-- eq(
-- '%#lualine_buffers_active_no_mode#%6@LualineSwitchBuffer@ [No Name] %T%#lualine_transitional_lualine_buffers_active_no_mode_to_lualine_c_normal#%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- vim.bo.modified = true
-- eq(
-- '%#lualine_buffers_active_no_mode#%6@LualineSwitchBuffer@ [No Name] + %T%#lualine_transitional_lualine_buffers_active_no_mode_to_lualine_c_normal#%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- vim.bo.modified = false
-- end)
--
-- it('can show relative path', function()
-- local conf = vim.deepcopy(tab_conf)
-- conf.tabline.lualine_a = { { 'buffers', max_length = 1e3, show_filename_only = false, icons_enabled = false } }
-- require('lualine').setup(conf)
-- require('lualine').statusline()
-- vim.cmd('e ' .. os.tmpname())
-- eq(
-- '%#lualine_buffers_active_no_mode#%6@LualineSwitchBuffer@ '
-- .. vim.fn.pathshorten(vim.fn.expand '%:p:.')
-- .. ' %T%#lualine_transitional_lualine_buffers_active_no_mode_to_lualine_c_normal#%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- end)
--
-- it('can show ellipsis when max_width is crossed', function()
-- local conf = vim.deepcopy(tab_conf)
-- conf.tabline.lualine_a = { { 'buffers', max_length = 1 } }
-- vim.cmd 'tabe a.txt'
-- vim.cmd 'tabe b.txt'
-- vim.cmd 'tabprev'
-- require('lualine').setup(conf)
-- require('lualine').statusline()
-- eq(
-- '%#lualine_buffers_active_no_mode#%4@LualineSwitchBuffer@ a.txt %T%#lualine_transitional_lualine_buffers_active_no_mode_to_lualine_buffers_active_0_no_mode#%#lualine_buffers_active_0_no_mode#%5@LualineSwitchBuffer@ ... %T%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- end)
--
-- it('can show filetype icons', function()
-- local conf = vim.deepcopy(tab_conf)
-- conf.tabline.lualine_a = { { 'buffers', max_length = 1e3, show_filename_only = false } }
-- require('lualine').setup(conf)
-- require('lualine').statusline()
-- vim.cmd('e t.lua')
-- eq(
-- '%#lualine_buffers_active_no_mode#%7@LualineSwitchBuffer@  t.lua %T%#lualine_transitional_lualine_buffers_active_no_mode_to_lualine_c_normal#%#lualine_c_normal#%=',
-- require('lualine').tabline()
-- )
-- end)
--
-- end)
-- end)
end)