From f22ce4ff283ac48a50d999ee5fad56ac1e4d1dce Mon Sep 17 00:00:00 2001 From: Neil Mayhew Date: Fri, 11 Apr 2014 23:19:51 -0600 Subject: Add some unit tests for Writers.Docbook These are primarily aimed at testing the new treatment of line breaks, but hopefully other tests can be added more easily now as features and changes are implemented in the writer. Adapted from Tests.Writers.HTML.tests. --- tests/Tests/Writers/Docbook.hs | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/Tests/Writers/Docbook.hs (limited to 'tests/Tests/Writers') diff --git a/tests/Tests/Writers/Docbook.hs b/tests/Tests/Writers/Docbook.hs new file mode 100644 index 000000000..e815b4f5a --- /dev/null +++ b/tests/Tests/Writers/Docbook.hs @@ -0,0 +1,52 @@ +{-# LANGUAGE OverloadedStrings #-} +module Tests.Writers.Docbook (tests) where + +import Test.Framework +import Text.Pandoc.Builder +import Text.Pandoc +import Tests.Helpers +import Tests.Arbitrary() + +docbook :: (ToString a, ToPandoc a) => a -> String +docbook = writeDocbook def{ writerWrapText = False } . toPandoc + +{- + "my test" =: X =?> Y + +is shorthand for + + test docbook "my test" $ X =?> Y + +which is in turn shorthand for + + test docbook "my test" (X,Y) +-} + +infix 4 =: +(=:) :: (ToString a, ToPandoc a) + => String -> (a, String) -> Test +(=:) = test docbook + +lineblock :: Blocks +lineblock = para ("some text" <> linebreak <> + "and more lines" <> linebreak <> + "and again") +lineblock_out :: String +lineblock_out = "some text\n" ++ + "and more lines\n" ++ + "and again" + +tests :: [Test] +tests = [ testGroup "line blocks" + [ "none" =: para "This is a test" + =?> "\n This is a test\n" + , "basic" =: lineblock + =?> lineblock_out + , "blockquote" =: blockQuote lineblock + =?> ("
\n" ++ lineblock_out ++ "\n
") + , "footnote" =: para ("This is a test" <> note lineblock <> " of footnotes") + =?> ("\n This is a test\n" ++ + lineblock_out ++ + "\n of footnotes\n") + ] + ] -- cgit v1.2.3