1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
{-|
Module : Text.Jira.ParserTests
Copyright : © 2019–2023 Albert Krewinkel
License : MIT
Maintainer : Albert Krewinkel <tarleb@zeitkraut.de>
Stability : alpha
Portability : portable
Tests for the jira wiki parser.
-}
module Text.Jira.ParserTests (tests) where
import Data.Text ()
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (testCase, (@?=))
import Text.Jira.Parser
import qualified Text.Jira.Parser.BlockTests
import qualified Text.Jira.Parser.InlineTests
tests :: TestTree
tests = testGroup "Parser"
[ Text.Jira.Parser.InlineTests.tests
, Text.Jira.Parser.BlockTests.tests
, testGroup "doc"
[ testCase "empty document" $
parse "" @?=
Right (Doc [])
, testCase "simple document" $
parse "h1. test\nThis is ok." @?=
Right (Doc [ Header 1 [Str "test"]
, Para [Str "This", Space, Str "is", Space, Str "ok."]])
, testCase "leading blank lines" $
parse "\n\ntext\n" @?=
Right (Doc [Para [Str "text"]])
]
, testGroup "plainText"
[ testCase "word" $
plainText "kthxbye" @?=
Right [Str "kthxbye"]
, testCase "words" $
plainText "be Berlin" @?=
Right [Str "be", Space, Str "Berlin"]
, testCase "smiley" $
plainText ":)" @?=
Right [Str "\\:)"]
, testCase "smiley and text" $
plainText ":D lol" @?=
Right [Str "\\:D", Space, Str "lol"]
, testCase "icon after word" $
plainText "f(x)" @?=
Right [Str "f\\(x)"]
, testCase "icon-sequence at start of word" $
plainText ":PA" @?=
Right [SpecialChar ':', Str "PA"]
, testCase "icon-sequence followed by digit" $
plainText ":P2" @?=
Right [SpecialChar ':', Str "P2"]
, testCase "special chars" $
plainText "*not strong*" @?=
Right [SpecialChar '*', Str "not", Space, Str "strong", SpecialChar '*']
]
]
|