use animechan::quotes::*; macro_rules! aw { ($e:expr) => { tokio_test::block_on($e) }; } #[test] fn test_get_random() { let quote = aw!(get_random()).unwrap(); assert_ne!(quote.anime.trim().is_empty(), true); assert_ne!(quote.character.trim().is_empty(), true); assert_ne!(quote.quote.trim().is_empty(), true); } #[test] fn test_get_10_random() { let quotes = aw!(get_10_random()).unwrap(); assert_eq!(quotes.len(), 10); for i in 0..quotes.len() { assert_ne!(quotes[i].anime.trim().is_empty(), true); assert_ne!(quotes[i].character.trim().is_empty(), true); assert_ne!(quotes[i].quote.trim().is_empty(), true); } } #[test] fn test_get_from_title() { let quotes = aw!(get_from_title("naruto".to_string())).unwrap(); assert_ne!(quotes.is_empty(), true); for i in 0..quotes.len() { assert_eq!(quotes[i].anime.to_lowercase().contains("naruto"), true); assert_ne!(quotes[i].anime.trim().is_empty(), true); assert_ne!(quotes[i].character.trim().is_empty(), true); assert_ne!(quotes[i].quote.trim().is_empty(), true); } } #[test] fn test_get_from_title_with_pagination() { let quotes = aw!(get_from_title_at_page("naruto".to_string(), 2)).unwrap(); assert_ne!(quotes.is_empty(), true); for i in 0..quotes.len() { assert_eq!(quotes[i].anime.to_lowercase().contains("naruto"), true); assert_ne!(quotes[i].anime.trim().is_empty(), true); assert_ne!(quotes[i].character.trim().is_empty(), true); assert_ne!(quotes[i].quote.trim().is_empty(), true); } } #[test] fn test_get_from_character() { let quotes = aw!(get_from_character("naruto".to_string())).unwrap(); assert_ne!(quotes.is_empty(), true); for i in 0..quotes.len() { assert_ne!(quotes[i].character.trim().is_empty(), true); assert_ne!(quotes[i].anime.trim().is_empty(), true); assert_ne!(quotes[i].character.trim().is_empty(), true); assert_ne!(quotes[i].quote.trim().is_empty(), true); } } #[test] fn test_get_from_character_with_pagination() { let quotes = aw!(get_from_title_at_page("naruto".to_string(), 2)).unwrap(); assert_ne!(quotes.is_empty(), true); for i in 0..quotes.len() { assert_eq!(quotes[i].anime.to_lowercase(), "naruto"); assert_ne!(quotes[i].anime.trim().is_empty(), true); assert_ne!(quotes[i].character.trim().is_empty(), true); assert_ne!(quotes[i].quote.trim().is_empty(), true); } }