2021-09-20 11:46:38 +00:00
|
|
|
-- Copyright (c) 2020-2021 shadmansaleh
|
|
|
|
-- MIT license, see LICENSE for more details.
|
|
|
|
|
2021-05-09 21:11:18 +00:00
|
|
|
local eq = assert.are.same
|
|
|
|
|
|
|
|
describe('config parsing', function()
|
2022-01-02 11:38:39 +00:00
|
|
|
local config_module = require('lualine.config')
|
2021-05-09 21:11:18 +00:00
|
|
|
|
|
|
|
describe('options', function()
|
|
|
|
describe('icons_enabled', function()
|
|
|
|
it('default', function()
|
2022-02-01 08:04:03 +00:00
|
|
|
local config = config_module.apply_configuration {}
|
2021-08-02 06:40:11 +00:00
|
|
|
eq(config.options.icons_enabled, true)
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
it('custom', function()
|
2021-09-03 18:28:20 +00:00
|
|
|
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()
|
2022-02-01 08:04:03 +00:00
|
|
|
local config = config_module.apply_configuration {}
|
2021-08-14 06:02:30 +00:00
|
|
|
eq(config.options.theme, 'auto')
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
it('custom', function()
|
2021-09-03 18:28:20 +00:00
|
|
|
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-09-03 18:28:20 +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()
|
2022-02-01 08:04:03 +00:00
|
|
|
local config = config_module.apply_configuration {}
|
2021-09-14 15:14:23 +00:00
|
|
|
eq(config.options.component_separators, { left = '', right = '' })
|
|
|
|
eq(config.options.section_separators, { left = '', right = '' })
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
it('double separators', function()
|
|
|
|
local config = {
|
|
|
|
options = {
|
2021-09-14 15:14:23 +00:00
|
|
|
component_separators = { left = 'a', right = 'b' },
|
|
|
|
section_separators = { left = 'c', right = 'd' },
|
2021-09-03 18:28:20 +00:00
|
|
|
},
|
2021-05-09 21:11:18 +00:00
|
|
|
}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
2021-09-14 15:14:23 +00:00
|
|
|
eq(config.options.component_separators, { left = 'a', right = 'b' })
|
|
|
|
eq(config.options.section_separators, { left = 'c', right = 'd' })
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
|
|
|
|
describe('single separator', function()
|
|
|
|
it('string', function()
|
|
|
|
local config = {
|
2021-09-03 18:28:20 +00:00
|
|
|
options = { component_separators = 'a', section_separators = 'b' },
|
2021-05-09 21:11:18 +00:00
|
|
|
}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
2021-09-14 15:14:23 +00:00
|
|
|
eq(config.options.component_separators, { left = 'a', right = 'a' })
|
|
|
|
eq(config.options.section_separators, { left = 'b', right = 'b' })
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
it('table', function()
|
|
|
|
local config = {
|
2021-10-11 08:51:18 +00:00
|
|
|
options = {
|
|
|
|
component_separators = { left = 'a', right = 'b' },
|
|
|
|
section_separators = { left = 'b', right = 'a' },
|
|
|
|
},
|
2021-05-09 21:11:18 +00:00
|
|
|
}
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
2021-10-11 08:51:18 +00:00
|
|
|
eq(config.options.component_separators, { left = 'a', right = 'b' })
|
|
|
|
eq(config.options.section_separators, { left = 'b', right = 'a' })
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
end)
|
2023-03-30 04:12:37 +00:00
|
|
|
it('no separators', function()
|
2021-05-09 21:11:18 +00:00
|
|
|
local config = {
|
2021-09-03 18:28:20 +00:00
|
|
|
options = { component_separators = {}, section_separators = {} },
|
2021-05-09 21:11:18 +00:00
|
|
|
}
|
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()
|
2022-02-01 08:04:03 +00:00
|
|
|
local config = config_module.apply_configuration {}
|
2022-07-22 13:29:55 +00:00
|
|
|
eq(config.options.disabled_filetypes, {statusline={}, winbar={}})
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
it('custom', function()
|
2021-09-03 18:28:20 +00:00
|
|
|
local config = { options = { disabled_filetypes = { 'lua' } } }
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
2022-07-22 13:29:55 +00:00
|
|
|
eq(config.options.disabled_filetypes, {statusline={'lua'}, winbar={'lua'}})
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('non default global option', function()
|
|
|
|
it('default', function()
|
2021-09-03 18:28:20 +00:00
|
|
|
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()
|
2021-09-03 18:28:20 +00:00
|
|
|
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 = {
|
2021-09-03 18:28:20 +00:00
|
|
|
lualine_a = { 'mode' },
|
2021-12-09 17:18:11 +00:00
|
|
|
lualine_b = { 'branch', 'diff', 'diagnostics' },
|
2021-09-03 18:28:20 +00:00
|
|
|
lualine_c = { 'filename' },
|
|
|
|
lualine_x = { 'encoding', 'fileformat', 'filetype' },
|
|
|
|
lualine_y = { 'progress' },
|
|
|
|
lualine_z = { 'location' },
|
2021-05-09 21:11:18 +00:00
|
|
|
}
|
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 = {
|
2021-09-03 18:28:20 +00:00
|
|
|
lualine_a = { { 'mode', lower = true } },
|
|
|
|
lualine_b = { 'branch', { 'branch', lower = true } },
|
2021-05-09 21:11:18 +00:00
|
|
|
lualine_c = nil,
|
2021-09-03 18:28:20 +00:00
|
|
|
lualine_x = {},
|
2021-05-09 21:11:18 +00:00
|
|
|
}
|
|
|
|
local expected_sections = {
|
2021-09-03 18:28:20 +00:00
|
|
|
lualine_a = { { 'mode', lower = true } },
|
|
|
|
lualine_b = { 'branch', { 'branch', lower = true } },
|
|
|
|
lualine_c = { 'filename' },
|
2021-05-09 21:11:18 +00:00
|
|
|
lualine_x = {},
|
2021-09-03 18:28:20 +00:00
|
|
|
lualine_y = { 'progress' },
|
|
|
|
lualine_z = { 'location' },
|
2021-05-09 21:11:18 +00:00
|
|
|
}
|
2021-09-03 18:28:20 +00:00
|
|
|
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 = {
|
2021-09-03 18:28:20 +00:00
|
|
|
lualine_a = { { 'mode', lower = true } },
|
|
|
|
lualine_b = { 'branch', { 'branch', lower = true } },
|
2021-05-09 21:11:18 +00:00
|
|
|
lualine_c = nil,
|
2021-09-03 18:28:20 +00:00
|
|
|
lualine_x = {},
|
2021-05-09 21:11:18 +00:00
|
|
|
}
|
|
|
|
local expected_sections = {
|
2021-09-03 18:28:20 +00:00
|
|
|
lualine_a = { { 'mode', lower = true } },
|
|
|
|
lualine_b = { 'branch', { 'branch', lower = true } },
|
|
|
|
lualine_x = {},
|
2021-05-09 21:11:18 +00:00
|
|
|
}
|
2021-09-03 18:28:20 +00:00
|
|
|
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()
|
2021-09-03 18:28:20 +00:00
|
|
|
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()
|
2021-09-03 18:28:20 +00:00
|
|
|
local config = { extensions = { 'fugitive' } }
|
2021-08-02 06:40:11 +00:00
|
|
|
config = config_module.apply_configuration(config)
|
2021-09-03 18:28:20 +00:00
|
|
|
eq(config.extensions, { 'fugitive' })
|
2021-05-09 21:11:18 +00:00
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|