use cans::{world::Country, mime::*};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_delete_all_without_resetting_gmt() {
let mut cm = Country::new();
let country_code = "US";
let flag = cm.country_detail(country_code, "flag");
assert!(!flag.is_empty(), "The flag should not be empty for the US");
let gmt = cm.city_detail("US", "Washington, D.C.", "gmt");
assert!(
!gmt.is_empty(),
"GMT for Washington, D.C. should not be empty"
);
cm.delete_all();
let retrieved_gmt = cm.city_detail("US", "Washington, D.C.", "gmt");
assert_eq!(
retrieved_gmt, "",
"The GMT value should be an empty string after delete_all"
);
}
#[test]
fn test_delete_all_with_resetting_gmt() {
let mut cm = Country::new();
let country_code = "US";
let gmt = cm.city_detail(country_code, "Washington, D.C.", "gmt");
assert!(
!gmt.is_empty(),
"GMT for Washington, D.C. should not be empty"
);
cm.delete_all();
let gmt = "";
assert_eq!(
gmt, "",
"The variable gmt should now be an empty string after resetting it."
);
}
#[test]
fn test_set_mime_types() {
let mime_types = set_mime_types();
assert!(!mime_types.is_empty(), "MIME types HashMap should not be empty.");
assert_eq!(mime_types.get("html"), Some(&"text/html".to_string()));
assert_eq!(mime_types.get("png"), Some(&"image/png".to_string()));
assert_eq!(mime_types.get("json"), Some(&"application/json".to_string()));
}
#[test]
fn test_insert_mime_type() {
let mut mime_types = set_mime_types();
insert_mime_type(&mut mime_types, "custom_ext", "application/x-custom");
assert_eq!(mime_types.get("custom_ext"), Some(&"application/x-custom".to_string()));
}
#[test]
fn test_remove_mime_type() {
let mut mime_types = set_mime_types();
assert!(mime_types.contains_key("html"), "MIME type for 'html' should exist.");
remove_mime_type(&mut mime_types, "html");
assert!(!mime_types.contains_key("html"), "MIME type for 'html' should be removed.");
}
}