use crate::html::{HtmlRenderer, HtmlRendererOptions};
use ox_content_allocator::Allocator;
use ox_content_parser::Parser;
#[test]
fn test_convert_md_link_from_index_file() {
let allocator = Allocator::new();
let doc = Parser::new(&allocator, "[Docs](./docs.md)").parse().unwrap();
let mut renderer = HtmlRenderer::with_options(HtmlRendererOptions {
convert_md_links: true,
base_url: "/".to_string(),
source_path: "api/index.md".to_string(),
..Default::default()
});
let html = renderer.render(&doc);
insta::assert_snapshot!(html);
}
#[test]
fn test_convert_md_link_from_non_index_file() {
let allocator = Allocator::new();
let doc = Parser::new(&allocator, "[Docs](./docs.md)").parse().unwrap();
let mut renderer = HtmlRenderer::with_options(HtmlRendererOptions {
convert_md_links: true,
base_url: "/".to_string(),
source_path: "api/types.md".to_string(),
..Default::default()
});
let html = renderer.render(&doc);
insta::assert_snapshot!(html);
}
#[test]
fn test_convert_md_link_plain_relative_from_index() {
let allocator = Allocator::new();
let doc = Parser::new(&allocator, "[Types](types.md)").parse().unwrap();
let mut renderer = HtmlRenderer::with_options(HtmlRendererOptions {
convert_md_links: true,
base_url: "/".to_string(),
source_path: "api/index.md".to_string(),
..Default::default()
});
let html = renderer.render(&doc);
insta::assert_snapshot!(html);
}
#[test]
fn test_convert_mdx_and_markdown_links() {
let allocator = Allocator::new();
let doc = Parser::new(&allocator, "[Component](./component.mdx) [Guide](guide.markdown)")
.parse()
.unwrap();
let mut renderer = HtmlRenderer::with_options(HtmlRendererOptions {
convert_md_links: true,
base_url: "/".to_string(),
source_path: "api/index.mdx".to_string(),
..Default::default()
});
let html = renderer.render(&doc);
insta::assert_snapshot!(html);
}
#[test]
fn test_convert_md_link_parent_relative_from_index() {
let allocator = Allocator::new();
let doc = Parser::new(&allocator, "[Guide](../guide.md)").parse().unwrap();
let mut renderer = HtmlRenderer::with_options(HtmlRendererOptions {
convert_md_links: true,
base_url: "/".to_string(),
source_path: "api/index.md".to_string(),
..Default::default()
});
let html = renderer.render(&doc);
insta::assert_snapshot!(html);
}
#[test]
fn test_convert_md_link_parent_relative_from_non_index() {
let allocator = Allocator::new();
let doc = Parser::new(&allocator, "[Guide](../guide.md)").parse().unwrap();
let mut renderer = HtmlRenderer::with_options(HtmlRendererOptions {
convert_md_links: true,
base_url: "/".to_string(),
source_path: "api/types.md".to_string(),
..Default::default()
});
let html = renderer.render(&doc);
insta::assert_snapshot!(html);
}