1 // ██████╗ █████╗ ███████╗███████╗██╗███╗ ██╗ ██████╗ 2 // ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝ 3 // ██████╔╝███████║███████╗███████╗██║██╔██╗ ██║██║ ███╗ 4 // ██╔═══╝ ██╔══██║╚════██║╚════██║██║██║╚██╗██║██║ ██║ 5 // ██║ ██║ ██║███████║███████║██║██║ ╚████║╚██████╔╝ 6 // ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝ 7 8 #[cfg(test)] 9 mod passing { 10 use html5ever::serialize::{serialize, SerializeOpts}; 11 12 use crate::html; 13 14 #[test] basic()15 fn basic() { 16 let html = "<div>text</div>"; 17 let mut dom = html::html_to_dom(&html.as_bytes().to_vec(), str!()); 18 19 dom = html::add_favicon(&dom.document, "I_AM_A_FAVICON_DATA_URL".to_string()); 20 21 let mut buf: Vec<u8> = Vec::new(); 22 serialize(&mut buf, &dom.document, SerializeOpts::default()).unwrap(); 23 24 assert_eq!( 25 buf.iter().map(|&c| c as char).collect::<String>(), 26 "<html><head><link rel=\"icon\" href=\"I_AM_A_FAVICON_DATA_URL\"></link></head><body><div>text</div></body></html>" 27 ); 28 } 29 } 30