pandoc/test/Tests/Writers/Org.hs

69 lines
1.7 KiB
Haskell
Raw Normal View History

2017-02-12 15:09:07 +01:00
{-# LANGUAGE OverloadedStrings #-}
module Tests.Writers.Org (tests) where
import Data.Text as T
import Test.Tasty
2017-02-12 15:09:07 +01:00
import Tests.Helpers
import Text.Pandoc
import Text.Pandoc.Arbitrary ()
import Text.Pandoc.Builder
2017-02-12 15:09:07 +01:00
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
2017-02-12 15:09:07 +01:00
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"
]
, "ordered task list with starting number"
=: orderedListWith
(9, DefaultStyle, DefaultDelim)
[plain ("" <> space <> "a"), plain "☒ b"]
=?> T.unlines
[ "9. [@9] [ ] a"
, "10. [X] b"
]
, test (orgWithOpts def) "bullet without task_lists" $
bulletList [plain "☐ a", plain "☒ b"]
=?> T.unlines
[ "- ☐ a"
, "- ☒ b"
2017-02-12 15:09:07 +01:00
]
]
]