use super::*; // RULE: the file's type decides how the viewer shows it. #[test] fn the_type_decides() { assert_eq!(view_of(Some("application/pdf"), Some("Invented plan")), View::Pdf); assert_eq!(view_of(Some("text/csv; charset=utf-8"), None), View::Text); assert_eq!(view_of(Some("image/png"), Some("scan.pdf")), View::Picture); assert_eq!(view_of(Some("application/json"), None), View::Text); } // RULE: a type that says nothing (octet-stream, none) leaves it to the name's ending. #[test] fn a_type_that_says_nothing_leaves_it_to_the_name() { assert_eq!(view_of(Some("application/octet-stream"), Some("Invented Plan.PDF")), View::Pdf); assert_eq!(view_of(None, Some("notes.md")), View::Text); assert_eq!(view_of(None, Some("IMG-20261120-WA0001.jpg")), View::Picture); } // RULE: what Comms cannot draw is Other, so the viewer names it and offers another app. #[test] fn what_cannot_be_drawn_is_other() { assert_eq!(view_of(Some("application/vnd.openxmlformats-officedocument.wordprocessingml.document"), Some("Invented.docx")), View::Other); assert_eq!(view_of(Some("application/zip"), Some("a.zip")), View::Other); assert_eq!(view_of(None, None), View::Other); assert_eq!(view_of(None, Some("no-ending")), View::Other); }