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.
This commit is contained in:
parent
464d7a8e49
commit
f22ce4ff28
2 changed files with 54 additions and 0 deletions
52
tests/Tests/Writers/Docbook.hs
Normal file
52
tests/Tests/Writers/Docbook.hs
Normal file
|
@ -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 = "<literallayout>some text\n" ++
|
||||
"and more lines\n" ++
|
||||
"and again</literallayout>"
|
||||
|
||||
tests :: [Test]
|
||||
tests = [ testGroup "line blocks"
|
||||
[ "none" =: para "This is a test"
|
||||
=?> "<para>\n This is a test\n</para>"
|
||||
, "basic" =: lineblock
|
||||
=?> lineblock_out
|
||||
, "blockquote" =: blockQuote lineblock
|
||||
=?> ("<blockquote>\n" ++ lineblock_out ++ "\n</blockquote>")
|
||||
, "footnote" =: para ("This is a test" <> note lineblock <> " of footnotes")
|
||||
=?> ("<para>\n This is a test<footnote>\n" ++
|
||||
lineblock_out ++
|
||||
"\n </footnote> of footnotes\n</para>")
|
||||
]
|
||||
]
|
|
@ -12,6 +12,7 @@ import qualified Tests.Readers.RST
|
|||
import qualified Tests.Writers.ConTeXt
|
||||
import qualified Tests.Writers.LaTeX
|
||||
import qualified Tests.Writers.HTML
|
||||
import qualified Tests.Writers.Docbook
|
||||
import qualified Tests.Writers.Native
|
||||
import qualified Tests.Writers.Markdown
|
||||
import qualified Tests.Shared
|
||||
|
@ -27,6 +28,7 @@ tests = [ testGroup "Old" Tests.Old.tests
|
|||
, testGroup "ConTeXt" Tests.Writers.ConTeXt.tests
|
||||
, testGroup "LaTeX" Tests.Writers.LaTeX.tests
|
||||
, testGroup "HTML" Tests.Writers.HTML.tests
|
||||
, testGroup "Docbook" Tests.Writers.Docbook.tests
|
||||
, testGroup "Markdown" Tests.Writers.Markdown.tests
|
||||
]
|
||||
, testGroup "Readers"
|
||||
|
|
Loading…
Add table
Reference in a new issue