Skip to content

Commit

Permalink
Add some unit tests for SILE Writer
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jan 27, 2020
1 parent 61dd652 commit 8ad47b4
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion test/Tests/Writers/SILE.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"
]
]

0 comments on commit 8ad47b4

Please sign in to comment.