Lines
100 %
Functions
Branches
use super::backend::{ChartBackend, chart_backend, env_speaks_kitty, term_speaks_kitty};
#[test]
fn backend_follows_term_and_override() {
use ChartBackend::{Halfblocks, Kitty};
let cases = [
(None, None, Halfblocks),
(Some("xterm-256color"), None, Halfblocks),
(Some("xterm-kitty"), None, Kitty),
(Some("XTERM-KITTY"), None, Kitty),
(Some("xterm-ghostty"), None, Kitty),
(Some("ghostty"), None, Kitty),
(Some("xterm-kitty"), Some("halfblocks"), Halfblocks),
(Some("xterm-256color"), Some("kitty"), Kitty),
(None, Some("Kitty"), Kitty),
(Some("xterm-kitty"), Some("sixel"), Kitty),
(Some("xterm-256color"), Some(""), Halfblocks),
];
for (term, over, want) in cases {
assert_eq!(chart_backend(term, over), want, "{term:?} {over:?}");
}
fn term_detector_is_case_insensitive() {
assert!(term_speaks_kitty("Kitty"));
assert!(!term_speaks_kitty("screen"));
fn env_detector_takes_the_union_of_the_rules() {
let cases: [(&[(&str, &str)], bool); 11] = [
(&[], false),
(&[("TERM", "xterm-256color")], false),
(&[("KITTY_WINDOW_ID", "1")], true),
(&[("TERM", "xterm-kitty")], true),
(&[("TERM", "xterm-ghostty")], true),
(&[("TERM_PROGRAM", "kitty")], true),
(&[("TERM_PROGRAM", "ghostty")], true),
(&[("TERM_PROGRAM", "WezTerm")], true),
(&[("TERM_PROGRAM", "wezterm")], true),
(&[("TERM_PROGRAM", "Apple_Terminal")], false),
(&[("TERM", "screen"), ("TERM_PROGRAM", "tmux")], false),
for (vars, want) in cases {
let lookup = |name: &str| {
vars.iter()
.find(|(key, _)| *key == name)
.map(|(_, value)| (*value).to_string())
};
assert_eq!(env_speaks_kitty(lookup), want, "{vars:?}");