From c0b9757ab024a04fc9a6cb9cf4b307e42a0764c1 Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Thu, 26 Aug 2021 17:47:48 +0600 Subject: [PATCH] Fix tests --- lua/tests/spec/component_spec.lua | 8 +++++++- lua/tests/spec/utils_spec.lua | 19 +++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lua/tests/spec/component_spec.lua b/lua/tests/spec/component_spec.lua index fe4b28f..9394b36 100644 --- a/lua/tests/spec/component_spec.lua +++ b/lua/tests/spec/component_spec.lua @@ -79,7 +79,13 @@ describe('Component:', function() it('can apply default highlight', function() 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) describe('Global options:', function() diff --git a/lua/tests/spec/utils_spec.lua b/lua/tests/spec/utils_spec.lua index b4f9d76..b7a34f8 100644 --- a/lua/tests/spec/utils_spec.lua +++ b/lua/tests/spec/utils_spec.lua @@ -76,8 +76,7 @@ describe('Section genarator', function() require('lualine.components.special.function_component'):new(opts), require('lualine.components.special.function_component'):new(opts) } - eq( - '%#lualine_MySection_normal# test %#lualine_MySection_normal# test %#lualine_MySection_normal#', + eq( '%#lualine_MySection_normal# test %#lualine_MySection_normal# test ', sec.draw_section(section, 'MySection')) end) @@ -103,10 +102,8 @@ describe('Section genarator', function() } local highlight_name2 = 'lualine_'..section[2].options.component_name..'_no_mode' -- Removes separator on string color - eq( - '%#lualine_MySection_normal# test %#lualine_MySection_normal#%#' - ..highlight_name2..'#' - .. ' test %#lualine_MySection_normal# test %#lualine_MySection_normal#', + eq( '%#lualine_MySection_normal# test %#' ..highlight_name2..'#' + .. ' test %#lualine_MySection_normal# test ', sec.draw_section(section, 'MySection')) section[2] = require('lua.lualine.components.special.function_component'):new( @@ -114,9 +111,8 @@ describe('Section genarator', function() local highlight_name = '%#lualine_c_' .. section[2].options.component_name .. '_normal#' -- Removes separator on color with bg - eq('%#lualine_MySection_normal# test %#lualine_MySection_normal#' .. - highlight_name .. - ' test %#lualine_MySection_normal# test %#lualine_MySection_normal#', + eq('%#lualine_MySection_normal# test ' .. highlight_name .. + ' test %#lualine_MySection_normal# test ', sec.draw_section(section, 'MySection')) section[2] = require('lua.lualine.components.special.function_component'):new( @@ -124,9 +120,8 @@ describe('Section genarator', function() highlight_name2 = '%#lualine_c_' .. section[2].options.component_name .. '_normal#' -- Doesn't remove separator on color without bg - eq('%#lualine_MySection_normal# test %#lualine_MySection_normal#' .. - highlight_name2 .. - ' test %#lualine_MySection_normal# test %#lualine_MySection_normal#', + eq('%#lualine_MySection_normal# test ' .. highlight_name2 .. + ' test %#lualine_MySection_normal#%#lualine_MySection_normal# test ', sec.draw_section(section, 'MySection')) end) end)