lualine.nvim/lua/tests/helpers.lua
Hubert Pelczarski 82826ef661
refactor: moved loading to new module (#182)
* refactor: moved loading to new module
* refactor: check_single_separator
* refactor: simplified separator fixing
* refactor: tests/ -> lua/tests/
* refactor: moved to nvim_err_writeln for errors

* feat: moved config parsing to config.lua
* feat: get config directly from config module
* feat: added load_all function

* tests: config parsing tests

* added assert to luacheck globals
2021-05-09 23:11:18 +02:00

35 lines
1.1 KiB
Lua

local eq = assert.are.same
local M = {}
M.meths = setmetatable({}, {
__index = function(_, key) return vim.api['nvim_' .. key] end
})
-- Checks ouput of a component
M.assert_component = function(component, opts, result)
-- for testing global options
if component == nil then component = 'special.function_component' end
local comp = require('lualine.components.' .. component):new(opts)
eq(result, comp:draw(opts.hl))
end
-- sets defaults for component options
M.build_component_opts = function(opts)
if not opts then opts = {} end
if opts[1] == nil then opts[1] = function() return 'test' end end
if not opts.self then opts.self = {section = 'lualine_c'} end
if not opts.theme then opts.theme = 'gruvbox' end
if not opts.hl then opts.hl = '' end
if opts.icons_enabled == nil then opts.icons_enabled = true end
if not opts.component_separators then
opts.component_separators = {'', ''}
end
if not opts.section_separators then opts.section_separators = {'', ''} end
return opts
end
M.P = function(t) print(vim.inspect(t)) end
return M