pub mod app;
pub mod img;
pub mod pdf;
pub use app::*;
pub use img::*;
pub use pdf::*;
#[cfg(test)]
mod tests {
use crate::{ImgApp, ImgFormat, PdfApp, WkhtmlInput};
#[test]
fn test_pdf() {
let _ = env_logger::init();
let mut pdf_app = PdfApp::new().expect("Failed to init PDF Application");
pdf_app.set_arg("margin-top", Some("0".to_string())).unwrap();
let html_code = r#"<html><body><div>DEMO</div></body></html>"#.to_string();
let res = pdf_app.run(WkhtmlInput::Html(html_code), "demo");
assert!(res.is_ok(), "{}", res.unwrap_err());
let res = pdf_app.run(WkhtmlInput::File("examples/index.html".to_string()), "demo");
assert!(res.is_ok(), "{}", res.unwrap_err());
let res = pdf_app.run(
WkhtmlInput::Url("https://www.rust-lang.org/en-US/".to_string()),
"demo",
);
assert!(res.is_ok(), "{}", res.unwrap_err());
}
#[test]
fn test_img() {
let mut image_app = ImgApp::new().expect("Failed to init image Application");
let res = image_app
.set_format(ImgFormat::Png)
.unwrap()
.run(WkhtmlInput::File("examples/index.html".to_string()), "demo");
assert!(res.is_ok(), "{}", res.unwrap_err());
let res = image_app.run(
WkhtmlInput::Url("https://www.rust-lang.org/en-US/".to_string()),
"demo",
);
assert!(res.is_ok(), "{}", res.unwrap_err());
}
}