]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - tests/WikiParserTest.hs
Wrote more
[Rakka.git] / tests / WikiParserTest.hs
index d8772a192ebc2917f8fdfe100562b6eb2dfc65ca..f6f642cd06651049f11bd175f6842e6ced75d370 100644 (file)
@@ -3,6 +3,8 @@ module WikiParserTest
     )
     where
 
+import           Data.Maybe
+import           Network.URI
 import           Rakka.Wiki
 import           Rakka.Wiki.Parser
 import           Test.HUnit
@@ -117,6 +119,14 @@ testData = [ (parseWiki ""
               ~?=
               (Right []))
 
+           , (parseWiki "[[[Page]]]"
+              ~?=
+              (Right [ Paragraph [ ObjectLink "Page" Nothing ] ]))
+
+           , (parseWiki "[[[Page|foo]]]"
+              ~?=
+              (Right [ Paragraph [ ObjectLink "Page" (Just "foo") ] ]))
+
            , (parseWiki "[[Page]]"
               ~?= 
               (Right [ Paragraph [ PageLink (Just "Page") Nothing Nothing ]
@@ -320,4 +330,36 @@ testData = [ (parseWiki ""
                                               , Text "\n"
                                               , Text "bar"
                                               ]) ] ]))
+
+           , (parseWiki "<div>foo</div>"
+              ~?=
+              (Right [ BlockCmd (BlockCommand "div" []
+                                 [ Paragraph [Text "foo"] ]) ]))
+
+           , (parseWiki "<div>\nbar\n</div>"
+              ~?=
+              (Right [ BlockCmd (BlockCommand "div" []
+                                 [ Paragraph [Text "bar"] ]) ]))
+
+           , (parseWiki "<div><!-- comment --></div>"
+              ~?=
+              (Right [ BlockCmd (BlockCommand "div" [] []) ]))
+
+           , (parseWiki "foo<div id=\"bar\"/>"
+              ~?=
+              (Right [ Paragraph [Text "foo"]
+                     , BlockCmd (BlockCommand "div" [("id", "bar")] [])
+                     ]))
+
+           , (parseWiki "[http://example.org/]"
+              ~?=
+              (Right [ Paragraph [ExternalLink (fromJust $ parseURI "http://example.org/") Nothing] ]))
+
+           , (parseWiki "[http://example.org/ example.org]"
+              ~?=
+              (Right [ Paragraph [ExternalLink
+                                  (fromJust $ parseURI "http://example.org/")
+                                  (Just "example.org")
+                                 ]
+                     ]))
            ]