// ██████╗ █████╗ ███████╗███████╗██╗███╗ ██╗ ██████╗ // ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝ // ██████╔╝███████║███████╗███████╗██║██╔██╗ ██║██║ ███╗ // ██╔═══╝ ██╔══██║╚════██║╚════██║██║██║╚██╗██║██║ ██║ // ██║ ██║ ██║███████║███████║██║██║ ╚████║╚██████╔╝ // ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝ #[cfg(test)] mod passing { use crate::html; #[test] fn div_as_root_element() { let html = "
"; let dom = html::html_to_dom(&html); let opt_no_css: bool = false; let opt_no_fonts: bool = false; let opt_no_frames: bool = false; let opt_no_js: bool = false; let opt_no_images: bool = false; let opt_isolate: bool = false; assert_eq!( html::stringify_document( &dom.document, opt_no_css, opt_no_fonts, opt_no_frames, opt_no_js, opt_no_images, opt_isolate, ), "
" ); } #[test] fn full_page_with_no_html_head_or_body() { let html = "Isolated document\ \ \
"; let dom = html::html_to_dom(&html); let opt_no_css: bool = false; let opt_no_fonts: bool = false; let opt_no_frames: bool = false; let opt_no_js: bool = false; let opt_no_images: bool = false; let opt_isolate: bool = true; assert_eq!( html::stringify_document( &dom.document, opt_no_css, opt_no_fonts, opt_no_frames, opt_no_js, opt_no_images, opt_isolate, ), "\ \ \ Isolated document\ \ \ \ \
\ \
\ \ " ); } #[test] fn doctype_and_the_rest_no_html_head_or_body() { let html = "\ Unstyled document\ \
"; let dom = html::html_to_dom(&html); let opt_no_css: bool = true; let opt_no_fonts: bool = false; let opt_no_frames: bool = false; let opt_no_js: bool = false; let opt_no_images: bool = false; let opt_isolate: bool = false; assert_eq!( html::stringify_document( &dom.document, opt_no_css, opt_no_fonts, opt_no_frames, opt_no_js, opt_no_images, opt_isolate, ), "\ \ \ \ Unstyled document\ \ \
\ " ); } #[test] fn doctype_and_the_rest_no_html_head_or_body_forbid_frames() { let html = "\ Frameless document\ \
"; let dom = html::html_to_dom(&html); let opt_no_css: bool = false; let opt_no_fonts: bool = false; let opt_no_frames: bool = true; let opt_no_js: bool = false; let opt_no_images: bool = false; let opt_isolate: bool = false; assert_eq!( html::stringify_document( &dom.document, opt_no_css, opt_no_fonts, opt_no_frames, opt_no_js, opt_no_images, opt_isolate, ), "\ \ \ \ Frameless document\ \ \
\ " ); } #[test] fn doctype_and_the_rest_all_forbidden() { let html = "\ no-frame no-css no-js no-image isolated document\ \ \
\ \ \ \
"; let dom = html::html_to_dom(&html); let opt_isolate: bool = true; let opt_no_css: bool = true; let opt_no_fonts: bool = true; let opt_no_frames: bool = true; let opt_no_js: bool = true; let opt_no_images: bool = true; assert_eq!( html::stringify_document( &dom.document, opt_no_css, opt_no_fonts, opt_no_frames, opt_no_js, opt_no_images, opt_isolate, ), "\ \ \ \ no-frame no-css no-js no-image isolated document\ \ \ \ \
\ \ \ \
\ \ " ); } }