module MdToHtmlTest where
import MdToHTML
import Test.HUnit
check_equal :: String -> String -> String -> Test
check_equal desc expected actual = TestCase (assertEqual desc expected actual)
convert :: String -> String
convert md = show . fst $ leftmostLongestParse parseDocument md
headerTests = TestList
[
check_equal "Should convert H1 heading" "
Hello
" (convert "# Hello"),
check_equal "Should convert H2 heading" "Hello
" (convert "## Hello"),
check_equal "Should convert H3 heading" "Hello
" (convert "### Hello"),
check_equal "Should convert H4 heading" "Hello
" (convert "#### Hello"),
check_equal "Should convert H5 heading" "Hello
" (convert "##### Hello"),
check_equal "Should convert H6 heading" "Hello
" (convert "###### Hello")
]
boldTests = TestList
[
check_equal "Should convert bold" "Hello
" (convert "__Hello__"),
check_equal "Should convert italic" "Hello
" (convert "_Hello_"),
check_equal "Should convert bold and italic in a sentence" "It is a wonderful day
" (convert "It _is_ a __wonderful__ day")
]
integrationTests = TestList
[
check_equal "Integration 1" "Sample Markdown
This is some basic, sample markdown.
Second Heading
" (convert "# Sample Markdown\n\n This is some basic, sample markdown.\n\n ## __Second__ _Heading_")
-- Add a test for single-newlines.
]
tests = TestList
[
headerTests,
boldTests,
integrationTests
]
runTests = runTestTT tests