From 58ce13aa29316b52ef30179a2b1cf2ee6ea39624 Mon Sep 17 00:00:00 2001 From: mehmetcansahin Date: Fri, 6 May 2022 16:40:25 +0300 Subject: [PATCH] update lib.rs --- src/lib.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 2c84727..9989f13 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,3 @@ -#![feature(async_closure, bool_to_option)] //! # site_icons //! An efficient website icon scraper. //! @@ -47,3 +46,24 @@ static CLIENT: Lazy = Lazy::new(|| { headers.insert(USER_AGENT, HeaderValue::from_str("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36").unwrap()); Client::builder().default_headers(headers).build().unwrap() }); + +#[cfg(test)] +mod tests { + use super::*; + #[tokio::test] + async fn test_icons() { + let mut icons = Icons::new(); + // scrape the icons from a url + icons.load_website("https://github.com").await.unwrap(); + + // fetch all icons, ensuring they exist & determining size + let entries = icons.entries().await; + + // entries are sorted from highest to lowest resolution + for icon in &entries { + println!("{:?}", icon) + } + + assert_eq!(entries.len() > 0, true); + } +}