Skip to content

Commit b93f4d7

Browse files
committed
test(tui): cover unread-to-accent theme fallback
CodeRabbit follow-up on agent-of-empires#2088: add unit tests for `fill_unread_from_accent` so the fallback can't break silently. Covers a custom theme that omits `unread` (inherits its own accent) and one that sets it explicitly (kept, not overwritten). 🤖 Generated with Claude Code
1 parent ca261e0 commit b93f4d7

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/tui/styles/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,30 @@ mod tests {
228228
assert!(matches!(theme.title, Color::Indexed(_)));
229229
}
230230

231+
#[test]
232+
fn custom_theme_without_unread_inherits_accent() {
233+
// A theme TOML that omits `unread` should fall back to that theme's
234+
// own accent, not Empire's default blue.
235+
let toml_str = "background = \"#1a1b26\"\naccent = \"#7aa2f7\"\n";
236+
let theme: Theme = toml::from_str(toml_str).unwrap();
237+
let theme = fill_unread_from_accent(toml_str, theme);
238+
assert_eq!(theme.accent, Color::Rgb(0x7a, 0xa2, 0xf7));
239+
assert_eq!(
240+
theme.unread, theme.accent,
241+
"omitted unread field should fall back to accent"
242+
);
243+
}
244+
245+
#[test]
246+
fn custom_theme_with_explicit_unread_preserves_it() {
247+
// An explicit `unread` must win over the accent fallback.
248+
let toml_str = "background = \"#1a1b26\"\naccent = \"#7aa2f7\"\nunread = \"#ff0000\"\n";
249+
let theme: Theme = toml::from_str(toml_str).unwrap();
250+
let theme = fill_unread_from_accent(toml_str, theme);
251+
assert_eq!(theme.unread, Color::Rgb(0xff, 0x00, 0x00));
252+
assert_ne!(theme.unread, theme.accent);
253+
}
254+
231255
#[test]
232256
fn load_theme_with_mode_truecolor_yields_rgb() {
233257
let theme = load_theme_with_mode("empire", false);

0 commit comments

Comments
 (0)