pandoc/test/Tests/Writers/Org.hs
Albert Krewinkel a3beed9db8 Org: support task_lists extension
The tasks lists extension is now supported by the org reader and writer;
the extension is turned on by default.

Closes: #6336
2021-02-13 13:00:37 -08:00

60 lines
1.4 KiB
Haskell

{-# LANGUAGE OverloadedStrings #-}
module Tests.Writers.Org (tests) where
import Data.Text as T
import Test.Tasty
import Tests.Helpers
import Text.Pandoc
import Text.Pandoc.Arbitrary ()
import Text.Pandoc.Builder
infix 4 =:
(=:) :: (ToString a, ToPandoc a)
=> String -> (a, Text) -> TestTree
(=:) = test org
defopts :: WriterOptions
defopts = def
{ writerExtensions = getDefaultExtensions "org"
}
org :: (ToPandoc a) => a -> Text
org = orgWithOpts defopts
orgWithOpts :: (ToPandoc a) => WriterOptions -> a -> Text
orgWithOpts opts x = purely (writeOrg opts) $ toPandoc x
tests :: [TestTree]
tests =
[ testGroup "links"
-- See http://orgmode.org/manual/Internal-links.html#Internal-links
[ "simple link"
=: link "/url" "" "foo"
=?> "[[/url][foo]]"
, "internal link to anchor"
=: link "#my-custom-id" "" "#my-custom-id"
=?> "[[#my-custom-id]]"
]
, testGroup "lists"
[ "bullet task list"
=: bulletList [plain "☐ a", plain "☒ b"]
=?> T.unlines
[ "- [ ] a"
, "- [X] b"
]
, "ordered task list"
=: orderedList [plain ("" <> space <> "a"), plain "☒ b"]
=?> T.unlines
[ "1. [ ] a"
, "2. [X] b"
]
, test (orgWithOpts def) "bullet without task_lists" $
bulletList [plain "☐ a", plain "☒ b"]
=?> T.unlines
[ "- ☐ a"
, "- ☒ b"
]
]
]