Sync local packages into the registry repo and update index.json and README.md to include all 9 packages.
93 lines
4.5 KiB
Plaintext
93 lines
4.5 KiB
Plaintext
import lib
|
|
|
|
// Integration tests: converting complex markdown documents
|
|
|
|
// Full blog post with mixed content
|
|
fn test_full_blog_post(): Unit with {Test} = {
|
|
let md = "# Welcome to My Blog\n\nThis is my **first post** about *Lux*.\n\n## Getting Started\n\nHere's some code:\n\n```lux\nfn main(): Unit = Console.print(\"hello\")\n```\n\nCheck out [the docs](https://example.com) for more.\n\n---\n\nThanks for reading!"
|
|
let html = lib.toHtml(md)
|
|
Test.assert(String.contains(html, "<h1>Welcome to My Blog</h1>"), "has h1")
|
|
Test.assert(String.contains(html, "<strong>first post</strong>"), "has bold")
|
|
Test.assert(String.contains(html, "<em>Lux</em>"), "has italic")
|
|
Test.assert(String.contains(html, "<h2>Getting Started</h2>"), "has h2")
|
|
Test.assert(String.contains(html, "<pre><code class=\"language-lux\">"), "has code block with lang")
|
|
Test.assert(String.contains(html, "<a href=\"https://example.com\">the docs</a>"), "has link")
|
|
Test.assert(String.contains(html, "<hr>"), "has horizontal rule")
|
|
Test.assert(String.contains(html, "Thanks for reading!"), "has closing paragraph")
|
|
}
|
|
|
|
// Document with various list types
|
|
fn test_mixed_lists(): Unit with {Test} = {
|
|
let md = "Shopping list:\n\n- Apples\n- Bananas\n- Cherries\n\nSteps:\n\n1. Preheat oven\n2. Mix ingredients\n3. Bake for 30 min"
|
|
let html = lib.toHtml(md)
|
|
Test.assert(String.contains(html, "<ul>"), "has unordered list")
|
|
Test.assert(String.contains(html, "<ol>"), "has ordered list")
|
|
Test.assert(String.contains(html, "<li>Apples</li>"), "has UL item")
|
|
Test.assert(String.contains(html, "<li>Preheat oven</li>"), "has OL item")
|
|
}
|
|
|
|
// Nested inline formatting
|
|
fn test_nested_inline(): Unit with {Test} = {
|
|
let result = lib.inlineToHtml("**bold and *italic* inside**")
|
|
Test.assert(String.contains(result, "<strong>"), "has strong tag")
|
|
Test.assert(String.contains(result, "<em>italic</em>"), "has nested italic")
|
|
}
|
|
|
|
// Multiple paragraphs
|
|
fn test_multiple_paragraphs(): Unit with {Test} = {
|
|
let md = "First paragraph.\n\nSecond paragraph.\n\nThird paragraph."
|
|
let html = lib.toHtml(md)
|
|
Test.assert(String.contains(html, "<p>First paragraph.</p>"), "first para")
|
|
Test.assert(String.contains(html, "<p>Second paragraph.</p>"), "second para")
|
|
Test.assert(String.contains(html, "<p>Third paragraph.</p>"), "third para")
|
|
}
|
|
|
|
// Code block preserves content exactly
|
|
fn test_code_block_preserves_content(): Unit with {Test} = {
|
|
let md = "```html\n<div>\n <p>Hello & world</p>\n</div>\n```"
|
|
let html = lib.toHtml(md)
|
|
Test.assert(String.contains(html, "language-html"), "has language class")
|
|
Test.assert(String.contains(html, "<div>"), "HTML tags in code are escaped")
|
|
Test.assert(String.contains(html, "& world"), "ampersand in code is escaped")
|
|
}
|
|
|
|
// Heading with various inline elements
|
|
fn test_heading_with_link(): Unit with {Test} = {
|
|
let md = "## [Lux](https://example.com) Language"
|
|
let html = lib.toHtml(md)
|
|
Test.assert(String.contains(html, "<h2>"), "has h2")
|
|
Test.assert(String.contains(html, "<a href=\"https://example.com\">Lux</a>"), "has link in heading")
|
|
}
|
|
|
|
// Blockquote with inline formatting
|
|
fn test_blockquote_with_formatting(): Unit with {Test} = {
|
|
let md = "> This is a **bold** quote"
|
|
let html = lib.toHtml(md)
|
|
Test.assert(String.contains(html, "<blockquote>"), "has blockquote")
|
|
Test.assert(String.contains(html, "<strong>bold</strong>"), "has bold in blockquote")
|
|
}
|
|
|
|
// Document starting with code block
|
|
fn test_leading_code_block(): Unit with {Test} = {
|
|
let md = "```\ncode first\n```\n\nThen text."
|
|
let html = lib.toHtml(md)
|
|
Test.assert(String.contains(html, "<pre><code>code first"), "code block first")
|
|
Test.assert(String.contains(html, "<p>Then text.</p>"), "paragraph after code")
|
|
}
|
|
|
|
// Images in context
|
|
fn test_image_in_paragraph(): Unit with {Test} = {
|
|
let md = "Here is a photo:\n\n\n\nBeautiful, right?"
|
|
let html = lib.toHtml(md)
|
|
Test.assert(String.contains(html, "<img src=\"sunset.jpg\" alt=\"Sunset\">"), "has image")
|
|
}
|
|
|
|
// List items with headings
|
|
fn test_list_with_headings(): Unit with {Test} = {
|
|
let md = "- ## Chapter 1\n- ## Chapter 2\n- ## Chapter 3"
|
|
let html = lib.toHtml(md)
|
|
Test.assert(String.contains(html, "<li><h2>Chapter 1</h2></li>"), "heading in list item 1")
|
|
Test.assert(String.contains(html, "<li><h2>Chapter 2</h2></li>"), "heading in list item 2")
|
|
Test.assert(String.contains(html, "<li><h2>Chapter 3</h2></li>"), "heading in list item 3")
|
|
}
|