// ██████╗ █████╗ ███████╗███████╗██╗███╗ ██╗ ██████╗ // ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝ // ██████╔╝███████║███████╗███████╗██║██╔██╗ ██║██║ ███╗ // ██╔═══╝ ██╔══██║╚════██║╚════██║██║██║╚██╗██║██║ ██║ // ██║ ██║ ██║███████║███████║██║██║ ╚████║╚██████╔╝ // ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝ #[cfg(test)] mod passing { use assert_cmd::prelude::*; use std::env; use std::fs; use std::path::Path; use std::process::Command; use url::Url; #[test] fn parse_noscript_contents() { let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); let path_html: &Path = Path::new("src/tests/data/noscript/index.html"); let path_svg: &Path = Path::new("src/tests/data/noscript/image.svg"); let out = cmd.arg("-M").arg(path_html.as_os_str()).output().unwrap(); // STDOUT should contain HTML with no CSS assert_eq!( std::str::from_utf8(&out.stdout).unwrap(), "
\n\n" ); // STDERR should contain target HTML and embedded SVG files assert_eq!( std::str::from_utf8(&out.stderr).unwrap(), format!( "\ {file_url_html}\n \ {file_url_svg}\n\ ", file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()) .unwrap() .into_string(), file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()) .unwrap() .into_string(), ) ); // The exit code should be 0 out.assert().code(0); } #[test] fn unwrap_noscript_contents() { let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); let path_html: &Path = Path::new("src/tests/data/noscript/index.html"); let path_svg: &Path = Path::new("src/tests/data/noscript/image.svg"); let out = cmd.arg("-Mn").arg(path_html.as_os_str()).output().unwrap(); // STDOUT should contain HTML with no CSS assert_eq!( std::str::from_utf8(&out.stdout).unwrap(), "\n\n" ); // STDERR should contain target HTML and embedded SVG files assert_eq!( std::str::from_utf8(&out.stderr).unwrap(), format!( "\ {file_url_html}\n \ {file_url_svg}\n\ ", file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()) .unwrap() .into_string(), file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()) .unwrap() .into_string(), ) ); // The exit code should be 0 out.assert().code(0); } #[test] fn unwrap_noscript_contents_nested() { let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); let path_html: &Path = Path::new("src/tests/data/noscript/nested.html"); let path_svg: &Path = Path::new("src/tests/data/noscript/image.svg"); let out = cmd.arg("-Mn").arg(path_html.as_os_str()).output().unwrap(); // STDOUT should contain HTML with no CSS assert_eq!( std::str::from_utf8(&out.stdout).unwrap(), "