@@ -69,6 +69,50 @@ describe("UI Tests", function()
6969 })
7070 assert .is_equal (segment .text , " a_very_very_very_…" )
7171 end )
72+
73+ it (" should render an icon if show_modified is true" , function ()
74+ config .setup ({ options = { show_modified = true } })
75+ config .apply ()
76+ local buf = MockBuffer :new ({ id = 1 , name = " file.txt" , length = 10 , modified = true })
77+ local el = ui .element ({}, buf )
78+ local segment = ui .to_tabline_str (el :component (1 ))
79+ assert .is_truthy (segment :match (config .options .modified_icon ))
80+ end )
81+
82+ it (" should not render an icon if show_modified is false" , function ()
83+ config .setup ({ options = { show_modified = false } })
84+ config .apply ()
85+ local buf = MockBuffer :new ({ id = 1 , name = " file.txt" , length = 10 , modified = true })
86+ local el = ui .element ({}, buf )
87+ local segment = ui .to_tabline_str (el :component (1 ))
88+ assert .is_falsy (segment :match (config .options .modified_icon ))
89+ end )
90+
91+ it (" should render an icon if show_modified is active" , function ()
92+ config .setup ({ options = { show_modified = " active" } })
93+ config .apply ()
94+ local buf1 = MockBuffer :new ({ id = 1 , name = " file.txt" , length = 10 , modified = true , _is_current = true })
95+ local buf2 = MockBuffer :new ({ id = 1 , name = " file.txt" , length = 10 , modified = true , _is_current = false })
96+ local el1 = ui .element ({}, buf1 )
97+ local el2 = ui .element ({}, buf2 )
98+ local segment1 = ui .to_tabline_str (el1 :component (1 ))
99+ local segment2 = ui .to_tabline_str (el2 :component (1 ))
100+ assert .is_truthy (segment1 :match (config .options .modified_icon ))
101+ assert .is_falsy (segment2 :match (config .options .modified_icon ))
102+ end )
103+
104+ it (" should render an icon if show_modified is inactive" , function ()
105+ config .setup ({ options = { show_modified = " inactive" } })
106+ config .apply ()
107+ local buf1 = MockBuffer :new ({ id = 1 , name = " file.txt" , length = 10 , modified = true , _is_current = false })
108+ local buf2 = MockBuffer :new ({ id = 1 , name = " file.txt" , length = 10 , modified = true , _is_current = true })
109+ local el1 = ui .element ({}, buf1 )
110+ local el2 = ui .element ({}, buf2 )
111+ local segment1 = ui .to_tabline_str (el1 :component (1 ))
112+ local segment2 = ui .to_tabline_str (el2 :component (1 ))
113+ assert .is_truthy (segment1 :match (config .options .modified_icon ))
114+ assert .is_falsy (segment2 :match (config .options .modified_icon ))
115+ end )
72116 end )
73117
74118 describe (" Hover events - " , function ()
0 commit comments