Added test for RST image parser

+ Fixed some small issues
This commit is contained in:
Joey Hines 2020-10-10 10:52:07 -05:00
parent 68ecb118a9
commit acddf5c51e
2 changed files with 18 additions and 3 deletions

View File

@ -27,7 +27,7 @@ impl RSTImage {
let mut style = "".to_string();
if let Some(alt) = &self.alt {
html = format!("{} {}", html, alt);
html = format!("{} alt=\"{}\"", html, alt);
}
if let Some(height) = &self.height {

View File

@ -1,5 +1,5 @@
#[cfg(test)]
use super::rst_parser::parse_links;
use super::rst_parser::{parse_links, parse_images};
#[test]
fn test_link_parser() {
@ -9,7 +9,22 @@ fn test_link_parser() {
.. _a link: https://domain.invalida\n",
);
let output = parse_links(&mut input);
let output = parse_links(&mut input).unwrap();
assert_eq!(output.trim_end(), "This is a paragraph that contains <a class=\"link\" href=\"https://domain.invalida\">a link</a>.")
}
#[test]
fn test_image_parser() {
let input =
".. image:: cool/image/123.png
:width: 60%
:height: auto
:alt: this is the alt text
";
let output = parse_images(input).unwrap();
assert_eq!(output.trim_end(), "<img src=\"cool/image/123.png\" alt=\"this is the alt text\" style=\"height;60%;width:60%;\">")
}