From e3d101e41f3b52f9452dedc49a8bc884d5b729df Mon Sep 17 00:00:00 2001 From: robertmercea Date: Sun, 23 Mar 2025 16:08:03 +0200 Subject: [PATCH 1/2] Add more file types to default theme test in color.rs --- src/color.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/color.rs b/src/color.rs index 9a3a14ba2..807d842a7 100644 --- a/src/color.rs +++ b/src/color.rs @@ -496,5 +496,29 @@ mod elem { .get_color(&test_theme()), Color::AnsiValue(184), ); + assert_eq!( + Elem::BrokenSymLink.get_color(&test_theme()), + Color::AnsiValue(124) + ); + assert_eq!( + Elem::Dir { uid: true }.get_color(&test_theme()), + Color::AnsiValue(33) + ); + assert_eq!( + Elem::Dir { uid: false }.get_color(&test_theme()), + Color::AnsiValue(33) + ); + assert_eq!( + Elem::BlockDevice.get_color(&test_theme()), + Color::AnsiValue(44) + ); + assert_eq!( + Elem::CharDevice.get_color(&test_theme()), + Color::AnsiValue(172) + ); + assert_eq!( + Elem::Special.get_color(&test_theme()), + Color::AnsiValue(44) + ); } } From 0afc26f775492bcf0a440890b0a7c616288a793e Mon Sep 17 00:00:00 2001 From: robertmercea Date: Sun, 23 Mar 2025 16:08:39 +0200 Subject: [PATCH 2/2] Add content style test in color.rs Signed-off-by: robertmercea --- src/color.rs | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/color.rs b/src/color.rs index 807d842a7..1eff5a65f 100644 --- a/src/color.rs +++ b/src/color.rs @@ -392,8 +392,9 @@ mod tests { #[cfg(test)] mod elem { use super::Elem; - use crate::theme::{color, color::ColorTheme}; - use crossterm::style::Color; + use crate::{color::to_content_style, theme::color::{self, ColorTheme}}; + use crossterm::style::{Attribute, Color, ContentStyle}; + use lscolors::FontStyle; #[cfg(test)] fn test_theme() -> ColorTheme { @@ -521,4 +522,28 @@ mod elem { Color::AnsiValue(44) ); } + + #[test] + fn test_content_style() { + let mut custom_content_style = ContentStyle { + foreground_color: Some(Color::DarkRed), + background_color: Some(Color::AnsiValue(50)), + ..ContentStyle::default() + }; + custom_content_style.attributes.set(Attribute::Bold); + + assert_eq!( + to_content_style(&lscolors::Style::default()), + ContentStyle::default() + ); + assert_eq!( + to_content_style(&lscolors::Style { + foreground: Some(lscolors::Color::Red), + background: Some(lscolors::Color::Fixed(50)), + font_style: FontStyle::bold(), + underline: Some(lscolors::Color::BrightBlue), + }), + custom_content_style + ); + } }