From 527b83d47764ab77c7b3ae124f26cc134abcd595 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 27 Jan 2020 18:18:26 +0300 Subject: [PATCH] Add some unit tests for SILE Writer --- test/Tests/Writers/SILE.hs | 43 +++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/test/Tests/Writers/SILE.hs b/test/Tests/Writers/SILE.hs index e85f7b291ac62..f68eb05af9a88 100644 --- a/test/Tests/Writers/SILE.hs +++ b/test/Tests/Writers/SILE.hs @@ -34,4 +34,45 @@ infix 4 =: (=:) = test sile tests :: [TestTree] -tests = [] +tests = [testGroup "BlockQuote" + [ "simple" =: blockQuote (para "foo") =?> + "\\begin{BlockQuote}\nfoo\n\\end{BlockQuote}" + ] + ,testGroup "BulletList" + [ "simple" =: bulletList [para "foo", para "bar"] =?> + "\\begin{BulletList}\n\\ListItem{foo}\n\\ListItem{bar}\n\\end{BulletList}" + ] + ,testGroup "CodeBlock" + [ "simple" =: codeBlock "foo" =?> + "\\begin{CodeBlock}\nfoo\n\\end{CodeBlock}" + , "with id" =: codeBlockWith ("bar", ["stuff"], []) "foo" =?> + "\\begin[id=bar,classes=\"stuff\"]{CodeBlock}\nfoo\n\\end{CodeBlock}" + ] + , testGroup "definition lists" + [ "with internal link" =: definitionList [(link "#go" "" (str "testing"), + [plain (text "hi there")])] =?> + "\\begin[tight=true]{DefinitionList}\n\\term{\\pdf:link[id=go]{testing}}\n\\definition{hi there}\n\\end{DefinitionList}" + ] + , testGroup "Header" + [ "chapter" =: header 0 (text "foo") =?> + "\\Header[level=0,type=chapter]{foo}" + , "section" =: header 1 (text "foo") =?> + "\\Header[level=1,type=section]{foo}" + , "subsection" =: header 2 (text "foo") =?> + "\\Header[level=2,type=subsection]{foo}" + -- , "part" =: header 0 (text "foo") =?> + -- "\\Header[level=-1,type=part]{foo}" + , "unnumbered with id note" =: + headerWith ("foo",["unnumbered"],[]) 1 + (text "foo" <> note (plain $ text "bar")) =?> + "\\Header[id=foo,classes=\"unnumbered\",level=1,type=section]{foo\\footnote{bar}}" + , "in list item" =: bulletList [header 2 (text "foo")] =?> + "\\begin{BulletList}\n\\ListItem{\\Header[level=2,type=subsection]{foo}}\n\\end{BulletList}" + , "in definition list item" =: + definitionList [(text "foo", [header 2 (text "bar"), + para $ text "baz"])] =?> + "\\begin{DefinitionList}\n\\term{foo}\n\\definition{\\Header[level=2,type=subsection]{bar}\n\nbaz}\n\\end{DefinitionList}" + , "containing image" =: header 1 (image "imgs/foo.jpg" "" (text "Alt text")) =?> + "\\Header[level=1,type=section]{\\img[src=imgs/foo.jpg]{Alt text}}" + ] + ]