Skip to content

Commit

Permalink
added a markdown text test (coverage for pandocBS), spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
wlangstroth committed Oct 24, 2010
1 parent 6abd018 commit 6507151
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Text/Templating/Heist/Types.hs
Expand Up @@ -9,7 +9,7 @@
{-|
This module contains the core Heist data types. TemplateMonad intentionally
does not expose any of it's functionality via MonadState or MonadReader
does not expose any of its functionality via MonadState or MonadReader
functions. We define passthrough instances for the most common types of
monads. These instances allow the user to use TemplateMonad in a monad stack
without needing calls to `lift`.
Expand Down
21 changes: 20 additions & 1 deletion test/suite/Text/Templating/Heist/Tests.hs
Expand Up @@ -31,6 +31,7 @@ import Text.Templating.Heist.Internal
import Text.Templating.Heist.Types
import Text.Templating.Heist.Splices.Apply
import Text.Templating.Heist.Splices.Ignore
import Text.Templating.Heist.Splices.Markdown
import Text.XML.Expat.Cursor
import Text.XML.Expat.Format
import qualified Text.XML.Expat.Tree as X
Expand All @@ -51,6 +52,7 @@ tests = [ testProperty "heist/simpleBind" simpleBindTest
, testCase "heist/attributeSubstitution" attrSubstTest
, testCase "heist/bindAttribute" bindAttrTest
, testCase "heist/markdown" markdownTest
, testCase "heist/markdownText" markdownTextTest
, testCase "heist/apply" applyTest
, testCase "heist/ignore" ignoreTest
]
Expand Down Expand Up @@ -203,12 +205,18 @@ bindAttrTest = do


------------------------------------------------------------------------------
htmlExpected :: ByteString
htmlExpected = "<div class=\"markdown\"><p>This <em>is</em> a test.</p></div>"


------------------------------------------------------------------------------
-- | Markdown test on a file
markdownTest :: H.Assertion
markdownTest = do
ets <- loadT "templates"
let ts = either (error "Error loading templates") id ets

check ts "<div class=\"markdown\"><p>This <em>is</em> a test.</p></div>"
check ts htmlExpected

where
check ts str = do
Expand All @@ -217,12 +225,23 @@ markdownTest = do
H.assertEqual ("Should match " ++ (show str)) str (fromJust result)


------------------------------------------------------------------------------
-- | Markdown test on supplied text
markdownTextTest :: H.Assertion
markdownTextTest = do
result <- evalTemplateMonad markdownSplice
(X.Text "This *is* a test.") emptyTemplateState
H.assertEqual "Markdown text" htmlExpected
(B.filter (/= '\n') $ formatList' result)


------------------------------------------------------------------------------
applyTest :: H.Assertion
applyTest = do
let es = emptyTemplateState :: TemplateState IO
res <- evalTemplateMonad applyImpl
(X.Element "apply" [("template", "nonexistant")] []) es

H.assertEqual "apply nothing" [] res


Expand Down

0 comments on commit 6507151

Please sign in to comment.