git.iko.soy/typeable/pandoc
on 8a3ef99 help sign in
34 lines 1.2 kB history raw
1{-# Language OverloadedStrings #-}
2module Tests.Lua ( tests ) where
4import System.FilePath ((</>))
5import Test.Tasty (TestTree)
6import Test.Tasty.HUnit (Assertion, assertEqual, testCase)
7import Text.Pandoc.Builder
8import Text.Pandoc.Lua
10tests :: [TestTree]
11tests =
12 [ testCase "macro expansion via filter" $
13 assertFilterConversion "a '{{helloworld}}' string is expanded"
14 "strmacro.lua"
15 (doc . para $ str "{{helloworld}}")
16 (doc . para . emph $ str "Hello, World")
18 , testCase "convert all plains to paras" $
19 assertFilterConversion "plains become para"
20 "plain-to-para.lua"
21 (doc $ bulletList [plain (str "alfa"), plain (str "bravo")])
22 (doc $ bulletList [para (str "alfa"), para (str "bravo")])
24 , testCase "make hello world document" $
25 assertFilterConversion "Document contains 'Hello, World!'"
26 "hello-world-doc.lua"
27 (doc . para $ str "Hey!" <> linebreak <> str "What's up?")
28 (doc . para $ str "Hello," <> space <> str "World!")
29 ]
31assertFilterConversion :: String -> FilePath -> Pandoc -> Pandoc -> Assertion
32assertFilterConversion msg filterPath docIn docExpected = do
33 docRes <- runLuaFilter ("lua" </> filterPath) [] docIn
34 assertEqual msg docExpected docRes