{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{- |
Module : Tests.Readers.DokuWiki
Copyright : © 2018-2020 Alexander Krotov
License : GNU GPL, version 2 or above
Maintainer : Alexander Krotov
Stability : alpha
Portability : portable
Tests for DokuWiki reader.
-}
module Tests.Readers.DokuWiki (tests) where
import Data.Text (Text)
import qualified Data.Text as T
import Test.Tasty
import Test.Tasty.HUnit (HasCallStack)
import Tests.Helpers
import Text.Pandoc
import Text.Pandoc.Arbitrary ()
import Text.Pandoc.Builder
dokuwiki :: Text -> Pandoc
dokuwiki = purely $ readDokuWiki def{ readerStandalone = True }
infix 4 =:
(=:) :: (ToString c, HasCallStack)
=> String -> (Text, c) -> TestTree
(=:) = test dokuwiki
tests :: [TestTree]
tests = [ testGroup "inlines"
[ "Bold" =:
"**bold**" =?>
para (strong "bold")
, "Italic" =:
"//italic//" =?>
para (emph "italic")
, "Underlined" =:
"__underlined__" =?>
para (underline "underlined")
, "Monospaced" =:
"''monospaced''" =?>
para (code "monospaced")
, "Monospaced with nowiki" =:
"''%%monospaced%%''" =?>
para (code "monospaced")
, "Combined" =:
"**__//''combine''//__**" =?>
para (strong $ underline $ emph $ code "combine")
, "Nowiki" =:
T.unlines [ " Hello Worlddeleted" =?>
para (strikeout "deleted")
, "Inline code" =:
"foo public static void main
bar" =?>
para (text "foo " <> codeWith ("", ["java"], []) "public static void main" <> text " bar")
, "Inline file" =:
"foo
"
, "some code"
, "comes here"
, "
"
, " - fourth item"
] =?>
orderedList [ plain "first item"
, plain ("second item with linebreak" <> linebreak <> " second line")
, plain ("third item with code: " <> code "some code\ncomes here\n")
, plain "fourth item"
]
]
, "Block HTML" =:
T.unlines [ ""
, "And this is some block HTML
" , "" ] =?> rawBlock "html" "And this is some block HTML
\n" , "Block PHP" =: T.unlines [ "Hello World
';" , ""
, "foo bar baz"
, "
"
] =?>
codeBlock "foo bar baz\n"
, "Java code block" =:
T.unlines [ ""
, "public static void main"
, "
"
] =?>
codeBlockWith ("", ["java"], []) "public static void main\n"
, "File with filename and no language" =:
T.unlines [ "