summaryrefslogtreecommitdiff
path: root/tests/Tests/Writers/HTML.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2012-07-26 08:37:36 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2012-07-26 08:37:36 -0700
commit45e4c123a45b83d666088967c25b91cf9bb5db72 (patch)
treeb3662354ccacd88b0d9238b3d0c049c4c876abc4 /tests/Tests/Writers/HTML.hs
parent3053267280bfd7b255f3bf47480e4a8a97ec2915 (diff)
Moved tests to tests/, modified cabal file so lib isn't recompiled.
Diffstat (limited to 'tests/Tests/Writers/HTML.hs')
-rw-r--r--tests/Tests/Writers/HTML.hs46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/Tests/Writers/HTML.hs b/tests/Tests/Writers/HTML.hs
new file mode 100644
index 000000000..8561aa421
--- /dev/null
+++ b/tests/Tests/Writers/HTML.hs
@@ -0,0 +1,46 @@
+{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}
+module Tests.Writers.HTML (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Tests.Arbitrary()
+import Text.Pandoc.Highlighting (languages) -- null if no hl support
+
+html :: (ToString a, ToPandoc a) => a -> String
+html = writeHtmlString defaultWriterOptions{ writerWrapText = False } . toPandoc
+
+{-
+ "my test" =: X =?> Y
+
+is shorthand for
+
+ test html "my test" $ X =?> Y
+
+which is in turn shorthand for
+
+ test html "my test" (X,Y)
+-}
+
+infix 4 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> Test
+(=:) = test html
+
+tests :: [Test]
+tests = [ testGroup "inline code"
+ [ "basic" =: code "@&" =?> "<code>@&amp;</code>"
+ , "haskell" =: codeWith ("",["haskell"],[]) ">>="
+ =?> if null languages
+ then "<code class=\"haskell\">&gt;&gt;=</code>"
+ else "<code class=\"sourceCode haskell\"><span class=\"fu\">&gt;&gt;=</span></code>"
+ , "nolanguage" =: codeWith ("",["nolanguage"],[]) ">>="
+ =?> "<code class=\"nolanguage\">&gt;&gt;=</code>"
+ ]
+ , testGroup "images"
+ [ "alt with formatting" =:
+ image "/url" "title" ("my " <> emph "image")
+ =?> "<img src=\"/url\" title=\"title\" alt=\"my image\" />"
+ ]
+ ]