summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorsamgd <sam@samgd.com>2016-07-25 12:47:30 +0200
committersamgd <sam@samgd.com>2016-07-25 12:47:30 +0200
commit82d6402ba38b9e1ea789e83c5ea7d08bcbeff467 (patch)
treeb0565d90ca1b681d6834adbde66e52ad133152cd /tests
parent43c969f326082d29d8e340ee865414deb87b8ac5 (diff)
downloadhakyll-82d6402ba38b9e1ea789e83c5ea7d08bcbeff467.tar.gz
Trim instructions. TrimRd chunk might need TrimL. Trim tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/Hakyll/Web/Template/Tests.hs14
-rw-r--r--tests/data/strip.html34
-rw-r--r--tests/data/strip.html.out18
3 files changed, 60 insertions, 6 deletions
diff --git a/tests/Hakyll/Web/Template/Tests.hs b/tests/Hakyll/Web/Template/Tests.hs
index 54d5406..994d9ca 100644
--- a/tests/Hakyll/Web/Template/Tests.hs
+++ b/tests/Hakyll/Web/Template/Tests.hs
@@ -13,6 +13,7 @@ import Test.HUnit (Assertion, (@=?), (@?=))
--------------------------------------------------------------------------------
import Hakyll.Core.Compiler
+import Hakyll.Core.Identifier
import Hakyll.Core.Item
import Hakyll.Core.Provider
import Hakyll.Web.Pandoc
@@ -26,7 +27,8 @@ import TestSuite.Util
--------------------------------------------------------------------------------
tests :: Test
tests = testGroup "Hakyll.Core.Template.Tests" $ concat
- [ [ testCase "case01" case01
+ [ [ testCase "case01" $ test ("template.html.out", "template.html", "example.md")
+ , testCase "case02" $ test ("strip.html.out", "strip.html", "example.md")
, testCase "applyJoinTemplateList" testApplyJoinTemplateList
]
@@ -78,14 +80,14 @@ tests = testGroup "Hakyll.Core.Template.Tests" $ concat
--------------------------------------------------------------------------------
-case01 :: Assertion
-case01 = do
+test :: (Identifier, Identifier, Identifier) -> Assertion
+test (outf, tplf, itemf) = do
store <- newTestStore
provider <- newTestProvider store
- out <- resourceString provider "template.html.out"
- tpl <- testCompilerDone store provider "template.html" templateBodyCompiler
- item <- testCompilerDone store provider "example.md" $
+ out <- resourceString provider outf
+ tpl <- testCompilerDone store provider tplf templateBodyCompiler
+ item <- testCompilerDone store provider itemf $
pandocCompiler >>= applyTemplate (itemBody tpl) testContext
out @=? itemBody item
diff --git a/tests/data/strip.html b/tests/data/strip.html
new file mode 100644
index 0000000..d28571e
--- /dev/null
+++ b/tests/data/strip.html
@@ -0,0 +1,34 @@
+<div>
+ I'm so rich I have $$3.
+
+ $rev("foo")$
+ $-rev(rev("foo"))$
+
+ $if(body)-$
+ I have body
+ $else-$
+ or no
+ $-endif-$
+
+ $if(unbound)$
+ should not be printed
+ $endif$
+
+ $-if(body)-$
+ should be printed
+ $-endif$
+
+ <ul>
+ $for(authors)-$
+ <li>$name$</li>
+ $endfor-$
+ </ul>
+
+ $for(authors)-$
+ $name-$
+ $sep$,
+ $-endfor$
+
+ $body$
+</div>
+
diff --git a/tests/data/strip.html.out b/tests/data/strip.html.out
new file mode 100644
index 0000000..9b37e69
--- /dev/null
+++ b/tests/data/strip.html.out
@@ -0,0 +1,18 @@
+<div>
+ I'm so rich I have $3.
+
+ ooffoo
+
+ I have body
+ should be printed
+
+ <ul>
+ <li>Jan</li>
+ <li>Piet</li>
+ </ul>
+
+ Jan,Piet
+
+ <p>This is an example.</p>
+</div>
+