aboutsummaryrefslogtreecommitdiff
path: root/test/Tests
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-11-01 00:37:29 -0400
committerGitHub <noreply@github.com>2017-11-01 00:37:29 -0400
commit1f393f1a8b4ffba6f4b81a42e5f1b51e6b771f63 (patch)
tree95ba2952b9dd40df82f3d6e84e98c4f37bc74cee /test/Tests
parent0b283252a54eb93bd7a3f71ccaa7f1022daad94b (diff)
parentd99776ea0405143d1b95f740a68b2a67cb0e73dd (diff)
downloadpandoc-1f393f1a8b4ffba6f4b81a42e5f1b51e6b771f63.tar.gz
Merge pull request #4001 from labdsf/fb2-tests
Add new style FB2 tests
Diffstat (limited to 'test/Tests')
-rw-r--r--test/Tests/Writers/FB2.hs34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/Tests/Writers/FB2.hs b/test/Tests/Writers/FB2.hs
new file mode 100644
index 000000000..77ab4a82c
--- /dev/null
+++ b/test/Tests/Writers/FB2.hs
@@ -0,0 +1,34 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Writers.FB2 (tests) where
+
+import Test.Tasty
+import Tests.Helpers
+import Text.Pandoc
+import Text.Pandoc.Arbitrary ()
+import Text.Pandoc.Builder
+
+fb2 :: String -> String
+fb2 x = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ++
+ "<FictionBook xmlns=\"http://www.gribuser.ru/xml/fictionbook/2.0\" xmlns:l=\"http://www.w3.org/1999/xlink\"><description><title-info /><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><annotation><p></p></annotation><section>" ++ x ++ "</section></body></FictionBook>"
+
+infix 4 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> TestTree
+(=:) = test (purely (writeFB2 def) . toPandoc)
+
+tests :: [TestTree]
+tests = [ testGroup "block elements"
+ ["para" =: para "Lorem ipsum cetera."
+ =?> fb2 "<p>Lorem ipsum cetera.</p>"
+ ]
+ , testGroup "inlines"
+ [
+ "Emphasis" =: emph ("emphasized")
+ =?> fb2 "<emphasis>emphasized</emphasis>"
+ ]
+ , "bullet list" =: bulletList [ plain $ text "first"
+ , plain $ text "second"
+ , plain $ text "third"
+ ]
+ =?> fb2 "<p>\x2022 first</p><p>\x2022 second</p><p>\x2022 third</p>"
+ ]