Skip to content

Commit 501eebb

Browse files
test: add test for directory icon consistency
1 parent 4b06f5d commit 501eebb

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/icon.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ mod test {
7777
use super::{IconTheme, Icons};
7878
use crate::flags::{IconOption, IconTheme as FlagTheme};
7979
use crate::meta::Meta;
80-
use std::fs::File;
80+
use std::fs::{create_dir_all, File};
8181
use tempfile::tempdir;
8282

8383
#[test]
@@ -234,4 +234,23 @@ mod test {
234234
assert_eq!(icon_str, format!("{}{}", file_icon, icon.icon_separator));
235235
}
236236
}
237+
238+
#[test]
239+
fn directory_icon_consistency() {
240+
let tmp_dir = tempdir().expect("failed to create temp dir");
241+
242+
for (ext, _) in &IconTheme::get_default_icons_by_extension() {
243+
let dir_path = tmp_dir.path().join(format!("folder.{ext}"));
244+
create_dir_all(&dir_path).expect("failed to create file");
245+
let meta = Meta::from_path(&dir_path, false, false).unwrap();
246+
247+
let icon = Icons::new(false, IconOption::Always, FlagTheme::Fancy, " ".to_string());
248+
let icon_str = icon.get(&meta.name);
249+
250+
assert_eq!(
251+
icon_str,
252+
format!("{}{}", "\u{f115}" /*  */, icon.icon_separator)
253+
);
254+
}
255+
}
237256
}

0 commit comments

Comments
 (0)