| 1 | |
| 2 | |
| 3 | use crate::menus::RowItem; |
| 4 | use crate::oracle::{Enable, RowCtx, row_enable, row_items}; |
| 5 | |
| 6 | fn ctx() -> RowCtx { |
| 7 | RowCtx { timeline: true, usable: true, ..RowCtx::default() } |
| 8 | } |
| 9 | |
| 10 | #[test] |
| 11 | fn a_missing_file_can_only_be_relinked() { |
| 12 | let gone = RowCtx { offline: true, ..ctx() }; |
| 13 | assert!(row_enable(RowItem::Relink, gone).yes()); |
| 14 | for item in [RowItem::Add, RowItem::Preview, RowItem::Proxy] { |
| 15 | assert_eq!(row_enable(item, gone), Enable::No("the file is missing")); |
| 16 | } |
| 17 | assert!(row_items(gone).contains(&RowItem::Relink)); |
| 18 | assert!(!row_items(ctx()).contains(&RowItem::Relink)); |
| 19 | } |
| 20 | |
| 21 | #[test] |
| 22 | fn a_refused_remove_says_why_in_plain_words() { |
| 23 | let used = RowCtx { placed: 1, ..ctx() }; |
| 24 | assert_eq!(row_enable(RowItem::Remove, used), Enable::No("It's used on the timeline")); |
| 25 | } |
| 26 | |
| 27 | #[test] |
| 28 | fn the_type_filter_tells_video_audio_and_images_apart() { |
| 29 | let ext = |name: &str| std::path::PathBuf::from(name); |
| 30 | assert!(crate::ui::dock_stance::kind_matches(1, &ext("a.mp4"))); |
| 31 | assert!(crate::ui::dock_stance::kind_matches(2, &ext("a.wav"))); |
| 32 | assert!(crate::ui::dock_stance::kind_matches(3, &ext("a.png"))); |
| 33 | assert!(!crate::ui::dock_stance::kind_matches(1, &ext("a.png"))); |
| 34 | } |