koda_cli/widgets/
file_menu.rs1use super::dropdown::DropdownItem;
7
8#[derive(Clone, Debug)]
10pub struct FileItem {
11 pub path: String,
13 pub is_dir: bool,
15}
16
17impl DropdownItem for FileItem {
18 fn label(&self) -> &str {
19 &self.path
20 }
21 fn description(&self) -> String {
22 if self.is_dir {
23 "\u{1f4c1}".to_string() } else {
25 String::new()
26 }
27 }
28 fn matches_filter(&self, _filter: &str) -> bool {
29 true
32 }
33}
34
35#[cfg(test)]
36mod tests {
37 use super::*;
38
39 #[test]
40 fn dir_shows_icon() {
41 let item = FileItem {
42 path: "src/".into(),
43 is_dir: true,
44 };
45 assert!(!item.description().is_empty());
46 }
47
48 #[test]
49 fn file_no_description() {
50 let item = FileItem {
51 path: "main.rs".into(),
52 is_dir: false,
53 };
54 assert!(item.description().is_empty());
55 }
56}