@@ -340,6 +340,69 @@ describe("file_history_render", function()
340340 end )
341341 end )
342342
343+ -- -----------------------------------------------------------------------
344+ -- subject_highlight
345+ -- -----------------------------------------------------------------------
346+
347+ describe (" subject_highlight" , function ()
348+ --- Replicate the subject highlight selection logic from render.lua.
349+ --- @param conf table
350+ --- @param entry table
351+ --- @param is_selected boolean
352+ --- @return string
353+ local function resolve_subject_hl (conf , entry , is_selected )
354+ if is_selected then
355+ return " DiffviewFilePanelSelected"
356+ elseif conf .file_history_panel .subject_highlight == " ref_aware" and entry .has_remote_ref then
357+ return " DiffviewCommitRemoteRef"
358+ elseif conf .file_history_panel .subject_highlight == " ref_aware" then
359+ return " DiffviewCommitLocalOnly"
360+ else
361+ return " DiffviewFilePanelFileName"
362+ end
363+ end
364+
365+ it (" uses DiffviewFilePanelFileName for 'plain' mode" , function ()
366+ local conf = config .get_config ()
367+ conf .file_history_panel .subject_highlight = " plain"
368+ config .setup (conf )
369+
370+ local entry = { has_remote_ref = true }
371+ eq (" DiffviewFilePanelFileName" , resolve_subject_hl (config .get_config (), entry , false ))
372+ end )
373+
374+ it (" uses DiffviewCommitRemoteRef for 'ref_aware' with remote ref" , function ()
375+ local conf = config .get_config ()
376+ conf .file_history_panel .subject_highlight = " ref_aware"
377+ config .setup (conf )
378+
379+ local entry = { has_remote_ref = true }
380+ eq (" DiffviewCommitRemoteRef" , resolve_subject_hl (config .get_config (), entry , false ))
381+ end )
382+
383+ it (" uses DiffviewCommitLocalOnly for 'ref_aware' without remote ref" , function ()
384+ local conf = config .get_config ()
385+ conf .file_history_panel .subject_highlight = " ref_aware"
386+ config .setup (conf )
387+
388+ local entry = { has_remote_ref = false }
389+ eq (" DiffviewCommitLocalOnly" , resolve_subject_hl (config .get_config (), entry , false ))
390+ end )
391+
392+ it (" uses DiffviewFilePanelSelected when entry is selected" , function ()
393+ local conf = config .get_config ()
394+ conf .file_history_panel .subject_highlight = " ref_aware"
395+ config .setup (conf )
396+
397+ local entry = { has_remote_ref = true }
398+ eq (" DiffviewFilePanelSelected" , resolve_subject_hl (config .get_config (), entry , true ))
399+ end )
400+
401+ it (" defaults to 'ref_aware'" , function ()
402+ eq (" ref_aware" , config .get_config ().file_history_panel .subject_highlight )
403+ end )
404+ end )
405+
343406 -- -----------------------------------------------------------------------
344407 -- date_format config default
345408 -- -----------------------------------------------------------------------
0 commit comments