use web_capture::markdown::convert_html_to_markdown;
#[test]
fn img_with_empty_title_must_not_emit_empty_title_in_markdown() {
let html = r#"<p><img alt="" title="" src="data:image/png;base64,iVBORw0KGgo="></p>"#;
let md = convert_html_to_markdown(html, None).unwrap();
assert!(md.contains(", "expected markdown image syntax: {md}");
assert!(
!md.contains(r#" "")"#),
"must NOT emit a trailing empty title attribute, got: {md}"
);
}
#[test]
fn img_with_empty_alt_must_not_emit_empty_title() {
let html = r#"<p><img alt="" src="data:image/png;base64,iVBORw0KGgo="></p>"#;
let md = convert_html_to_markdown(html, None).unwrap();
assert!(md.contains(", "expected markdown image syntax: {md}");
assert!(
!md.contains(r#" "")"#),
"must NOT emit a trailing empty title attribute, got: {md}"
);
}
#[test]
fn img_with_nonempty_title_keeps_title() {
let html = r#"<p><img alt="alt text" title="caption" src="https://example.com/img.png"></p>"#;
let md = convert_html_to_markdown(html, None).unwrap();
assert!(
md.contains(r#""caption""#),
"non-empty title must be preserved, got: {md}"
);
}