2021-05-09 21:11:18 +00:00
|
|
|
local eq = assert.are.same
|
|
|
|
|
|
|
|
describe('config parsing', function()
|
|
|
|
local config_module = require 'lualine.config'
|
|
|
|
|
|
|
|
describe('options', function()
|
|
|
|
describe('icons_enabled', function()
|
|
|
|
it('default', function()
|
2021-08-02 06:40:11 +00:00
|
|
|
local config = config_module.apply_configuration({})
|
|
|
|
eq(config.options.icons_enabled, true)
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
it('custom', function()
|
|
|
|
local config = {options = {icons_enabled = false}}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
|
|
|
eq(config.options.icons_enabled, false)
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('theme', function()
|
|
|
|
it('default', function()
|
2021-08-02 06:40:11 +00:00
|
|
|
local config = config_module.apply_configuration({})
|
|
|
|
eq(config.options.theme, 'gruvbox')
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
it('custom', function()
|
|
|
|
local config = {options = {theme = 'nord'}}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
|
|
|
eq(config.options.theme, 'nord')
|
2021-05-09 21:11:18 +00:00
|
|
|
config = {options = {theme = {}}}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
|
|
|
eq(config.options.theme, {})
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('separators', function()
|
|
|
|
it('default', function()
|
2021-08-02 06:40:11 +00:00
|
|
|
local config = config_module.apply_configuration({})
|
|
|
|
eq(config.options.component_separators, {'', ''})
|
|
|
|
eq(config.options.section_separators, {'', ''})
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
it('double separators', function()
|
|
|
|
local config = {
|
|
|
|
options = {
|
|
|
|
component_separators = {'a', 'b'},
|
|
|
|
section_separators = {'c', 'd'}
|
|
|
|
}
|
|
|
|
}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
|
|
|
eq(config.options.component_separators, {'a', 'b'})
|
|
|
|
eq(config.options.section_separators, {'c', 'd'})
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
|
|
|
|
describe('single separator', function()
|
|
|
|
it('string', function()
|
|
|
|
local config = {
|
|
|
|
options = {component_separators = 'a', section_separators = 'b'}
|
|
|
|
}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
|
|
|
eq(config.options.component_separators, {'a', 'a'})
|
|
|
|
eq(config.options.section_separators, {'b', 'b'})
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
it('table', function()
|
|
|
|
local config = {
|
|
|
|
options = {component_separators = {'a'}, section_separators = {'b'}}
|
|
|
|
}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
|
|
|
eq(config.options.component_separators, {'a', 'a'})
|
|
|
|
eq(config.options.section_separators, {'b', 'b'})
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
end)
|
|
|
|
it('no seprarators', function()
|
|
|
|
local config = {
|
|
|
|
options = {component_separators = {}, section_separators = {}}
|
|
|
|
}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
|
|
|
eq(config.options.component_separators, {})
|
|
|
|
eq(config.options.section_separators, {})
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('disabled filetypes', function()
|
|
|
|
it('default', function()
|
2021-08-02 06:40:11 +00:00
|
|
|
local config = config_module.apply_configuration({})
|
|
|
|
eq(config.options.disabled_filetypes, {})
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
it('custom', function()
|
|
|
|
local config = {options = {disabled_filetypes = {'lua'}}}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
|
|
|
eq(config.options.disabled_filetypes, {'lua'})
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('non default global option', function()
|
|
|
|
it('default', function()
|
|
|
|
local config = {options = {}}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
|
|
|
eq(config.options.non_default_global_option, nil)
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
it('custom', function()
|
|
|
|
local config = {options = {non_default_global_option = 1}}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
|
|
|
eq(config.options.non_default_global_option, 1)
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('sections', function()
|
|
|
|
it('default', function()
|
|
|
|
local config = {}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
2021-05-09 21:11:18 +00:00
|
|
|
local lualine_default_sections = {
|
|
|
|
lualine_a = {'mode'},
|
|
|
|
lualine_b = {'branch'},
|
|
|
|
lualine_c = {'filename'},
|
|
|
|
lualine_x = {'encoding', 'fileformat', 'filetype'},
|
|
|
|
lualine_y = {'progress'},
|
|
|
|
lualine_z = {'location'}
|
|
|
|
}
|
2021-08-02 06:40:11 +00:00
|
|
|
eq(config.sections, lualine_default_sections)
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
it('custom', function()
|
|
|
|
local custom_sections = {
|
|
|
|
lualine_a = {{'mode', lower = true}},
|
|
|
|
lualine_b = {'branch', {'branch', lower = true}},
|
|
|
|
lualine_c = nil,
|
|
|
|
lualine_x = {}
|
|
|
|
}
|
|
|
|
local expected_sections = {
|
|
|
|
lualine_a = {{'mode', lower = true}},
|
|
|
|
lualine_b = {'branch', {'branch', lower = true}},
|
|
|
|
lualine_c = {'filename'},
|
|
|
|
lualine_x = {},
|
|
|
|
lualine_y = {'progress'},
|
|
|
|
lualine_z = {'location'}
|
|
|
|
}
|
|
|
|
local config = {sections = custom_sections}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
|
|
|
eq(config.sections, expected_sections)
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('inactive_sections', function() end)
|
|
|
|
|
|
|
|
describe('tabline', function()
|
|
|
|
it('default', function()
|
|
|
|
local config = {}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
|
|
|
eq(config.tabline, {})
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
it('custom', function()
|
|
|
|
local custom_sections = {
|
|
|
|
lualine_a = {{'mode', lower = true}},
|
|
|
|
lualine_b = {'branch', {'branch', lower = true}},
|
|
|
|
lualine_c = nil,
|
|
|
|
lualine_x = {}
|
|
|
|
}
|
|
|
|
local expected_sections = {
|
|
|
|
lualine_a = {{'mode', lower = true}},
|
|
|
|
lualine_b = {'branch', {'branch', lower = true}},
|
|
|
|
lualine_x = {}
|
|
|
|
}
|
|
|
|
local config = {tabline = custom_sections}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
|
|
|
eq(config.tabline, expected_sections)
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('extensions', function()
|
|
|
|
it('default', function()
|
|
|
|
local config = {options = {}}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
|
|
|
eq(config.extensions, {})
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
it('custom', function()
|
|
|
|
local config = {extensions = {'fugitive'}}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
|
|
|
eq(config.extensions, {'fugitive'})
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|