@@ -0,0 +1,34 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+module Tests.Writers.FB2 (tests) where
3+
4+import Test.Tasty
5+import Tests.Helpers
6+import Text.Pandoc
7+import Text.Pandoc.Arbitrary ()
8+import Text.Pandoc.Builder
9+
10+fb2 :: String -> String
11+fb2 x = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ++
12+ "<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>"
13+
14+infix 4 =:
15+(=:) :: (ToString a, ToPandoc a)
16+ => String -> (a, String) -> TestTree
17+(=:) = test (purely (writeFB2 def) . toPandoc)
18+
19+tests :: [TestTree]
20+tests = [ testGroup "block elements"
21+ ["para" =: para "Lorem ipsum cetera."
22+ =?> fb2 "<p>Lorem ipsum cetera.</p>"
23+ ]
24+ , testGroup "inlines"
25+ [
26+ "Emphasis" =: emph ("emphasized")
27+ =?> fb2 "<emphasis>emphasized</emphasis>"
28+ ]
29+ , "bullet list" =: bulletList [ plain $ text "first"
30+ , plain $ text "second"
31+ , plain $ text "third"
32+ ]
33+ =?> fb2 "<p>\x2022 first</p><p>\x2022 second</p><p>\x2022 third</p>"
34+ ]