use markbase::render::{md_to_html, page, render_page};

#[test]
fn test_md_to_html_basic() {
    let md = "# Hello World\n\nThis is a test.";
    let html = md_to_html(md);

    assert!(html.contains("<h1>"));
    assert!(html.contains("Hello World"));
    assert!(html.contains("<p>"));
}

#[test]
fn test_md_to_html_table() {
    let md = "| Header 1 | Header 2 |\n|----------|----------|\n| Cell 1   | Cell 2   |";
    let html = md_to_html(md);

    assert!(html.contains("<table>"));
    assert!(html.contains("<thead>"));
    assert!(html.contains("<tbody>"));
}

#[test]
fn test_md_to_html_tasklist() {
    let md = "- [x] Completed task\n- [ ] Pending task";
    let html = md_to_html(md);

    assert!(html.contains("<li>"));
    assert!(html.contains("Completed task"));
}

#[test]
fn test_page_template() {
    let title = "Test Title";
    let content = "<p>Test content</p>";
    let html = page(title, content);

    assert!(html.contains(title));
    assert!(html.contains(content));
    assert!(html.contains("<!DOCTYPE html>") || html.contains("<html>"));
}

#[test]
fn test_render_page_mermaid() {
    let title = "Test";
    let content = "<code class=\"language-mermaid\">graph TD</code>";
    let html = render_page(title, content);

    assert!(html.contains("<div class=\"mermaid\">"));
    assert!(!html.contains("<code class=\"language-mermaid\">"));
    assert!(html.contains("startOnLoad:true"));
}
