Files
markbase/tests/render_test.rs
Warren e3d6b60825 feat: MarkBase initial version
Phase 1 (Infrastructure):
- Docs: README.md, AGENTS.md, CHANGELOG.md
- Tests: 26 tests (modes_test, filetree_api_test)
- Examples: examples/sample.md, sample.json
- CI/CD: .gitea/workflows/test.yml, release.yml
- Runner: configuration scripts and guides

Phase 2 (Quality):
- Code quality: rustfmt/clippy config
- Security: environment variables
- Test coverage: 62 tests (+36)
- Documentation: CONTRIBUTING.md, docs/api.yaml
- Showcase: demo_features.md, developer_quickstart.md

Test coverage: 75%
Test pass rate: 100%
2026-05-16 15:37:37 +08:00

53 lines
1.4 KiB
Rust

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"));
}