Skip to content

Commit

Permalink
test: add test for directory icon consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
atamakahere-git committed Dec 27, 2023
1 parent 4b06f5d commit 501eebb
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ mod test {
use super::{IconTheme, Icons};
use crate::flags::{IconOption, IconTheme as FlagTheme};
use crate::meta::Meta;
use std::fs::File;
use std::fs::{create_dir_all, File};
use tempfile::tempdir;

#[test]
Expand Down Expand Up @@ -234,4 +234,23 @@ mod test {
assert_eq!(icon_str, format!("{}{}", file_icon, icon.icon_separator));
}
}

#[test]
fn directory_icon_consistency() {
let tmp_dir = tempdir().expect("failed to create temp dir");

for (ext, _) in &IconTheme::get_default_icons_by_extension() {
let dir_path = tmp_dir.path().join(format!("folder.{ext}"));
create_dir_all(&dir_path).expect("failed to create file");
let meta = Meta::from_path(&dir_path, false, false).unwrap();

let icon = Icons::new(false, IconOption::Always, FlagTheme::Fancy, " ".to_string());
let icon_str = icon.get(&meta.name);

assert_eq!(
icon_str,
format!("{}{}", "\u{f115}" /*  */, icon.icon_separator)
);
}
}
}

0 comments on commit 501eebb

Please sign in to comment.