Fix tests

This commit is contained in:
shadmansaleh 2021-08-26 17:47:48 +06:00 committed by Shadman
parent c9b5f364dc
commit c0b9757ab0
2 changed files with 14 additions and 13 deletions

View File

@ -79,7 +79,13 @@ describe('Component:', function()
it('can apply default highlight', function() it('can apply default highlight', function()
local opts = build_component_opts({padding = 0, hl = '%#My_highlight#'}) local opts = build_component_opts({padding = 0, hl = '%#My_highlight#'})
assert_component(nil, opts, 'test%#My_highlight#') assert_component(nil, opts, '%#My_highlight#test')
opts = build_component_opts({function() return "%#Custom_hl#test" end,
padding = 0, hl = '%#My_highlight#'})
assert_component(nil, opts, '%#Custom_hl#test%#My_highlight#')
opts = build_component_opts({function() return "in middle%#Custom_hl#test" end,
padding = 0, hl = '%#My_highlight#'})
assert_component(nil, opts, '%#My_highlight#in middle%#Custom_hl#test%#My_highlight#')
end) end)
describe('Global options:', function() describe('Global options:', function()

View File

@ -76,8 +76,7 @@ describe('Section genarator', function()
require('lualine.components.special.function_component'):new(opts), require('lualine.components.special.function_component'):new(opts),
require('lualine.components.special.function_component'):new(opts) require('lualine.components.special.function_component'):new(opts)
} }
eq( eq( '%#lualine_MySection_normal# test %#lualine_MySection_normal# test ',
'%#lualine_MySection_normal# test %#lualine_MySection_normal# test %#lualine_MySection_normal#',
sec.draw_section(section, 'MySection')) sec.draw_section(section, 'MySection'))
end) end)
@ -103,10 +102,8 @@ describe('Section genarator', function()
} }
local highlight_name2 = 'lualine_'..section[2].options.component_name..'_no_mode' local highlight_name2 = 'lualine_'..section[2].options.component_name..'_no_mode'
-- Removes separator on string color -- Removes separator on string color
eq( eq( '%#lualine_MySection_normal# test %#' ..highlight_name2..'#'
'%#lualine_MySection_normal# test %#lualine_MySection_normal#%#' .. ' test %#lualine_MySection_normal# test ',
..highlight_name2..'#'
.. ' test %#lualine_MySection_normal# test %#lualine_MySection_normal#',
sec.draw_section(section, 'MySection')) sec.draw_section(section, 'MySection'))
section[2] = section[2] =
require('lua.lualine.components.special.function_component'):new( require('lua.lualine.components.special.function_component'):new(
@ -114,9 +111,8 @@ describe('Section genarator', function()
local highlight_name = local highlight_name =
'%#lualine_c_' .. section[2].options.component_name .. '_normal#' '%#lualine_c_' .. section[2].options.component_name .. '_normal#'
-- Removes separator on color with bg -- Removes separator on color with bg
eq('%#lualine_MySection_normal# test %#lualine_MySection_normal#' .. eq('%#lualine_MySection_normal# test ' .. highlight_name ..
highlight_name .. ' test %#lualine_MySection_normal# test ',
' test %#lualine_MySection_normal# test %#lualine_MySection_normal#',
sec.draw_section(section, 'MySection')) sec.draw_section(section, 'MySection'))
section[2] = section[2] =
require('lua.lualine.components.special.function_component'):new( require('lua.lualine.components.special.function_component'):new(
@ -124,9 +120,8 @@ describe('Section genarator', function()
highlight_name2 = highlight_name2 =
'%#lualine_c_' .. section[2].options.component_name .. '_normal#' '%#lualine_c_' .. section[2].options.component_name .. '_normal#'
-- Doesn't remove separator on color without bg -- Doesn't remove separator on color without bg
eq('%#lualine_MySection_normal# test %#lualine_MySection_normal#' .. eq('%#lualine_MySection_normal# test ' .. highlight_name2 ..
highlight_name2 .. ' test %#lualine_MySection_normal#%#lualine_MySection_normal# test ',
' test %#lualine_MySection_normal# test %#lualine_MySection_normal#',
sec.draw_section(section, 'MySection')) sec.draw_section(section, 'MySection'))
end) end)
end) end)