{-# LANGUAGE NoImplicitPrelude, QuasiQuotes, OverloadedStrings, UnicodeSyntax #-} module Data.Microformats2.ParserSpec (spec) where import Prelude.Compat import Test.Hspec hiding (shouldBe) import Test.Hspec.Expectations.Pretty (shouldBe) import TestCommon import Network.URI (parseURI) import Data.Microformats2.Parser spec ∷ Spec spec = do describe "parseItems" $ do let parseMf2'' c = parseMf2 c . documentRoot . parseLBS let parseMf2' = parseMf2'' def it "parses items" $ do parseMf2' [xml|
|] `shouldBe` [json|{ "items": [ { "type": [ "h-something", "h-something-else" ], "properties": { "org": [ { "type": [ "h-card" ], "properties": { "name": [ "Card" ] }, "value": "Card" }, { "type": [ "h-card" ], "properties": { "name": [ "org" ], "url": [ "http:\/\/card.url" ] }, "value": "org" } ], "url": [ "http:\/\/main.url" ], "name": [ "Name", "other name" ], "content": [ { "html": "Some XSS", "value": "Some XSS" } ], "published": [ "17th of July 2015 at 21:05", "2015-07-17T21:05:13+00:00" ], "updated": [ "2015-07-17T21:05:13+00:00" ] }, "children": [ { "type": [ "h-nested-something" ], "properties": { "name": [ "haz name" ] }, "value": "haz name" }, { "type": [ "h-area" ], "properties": {}, "shape": "circle", "coords": "200,250,25" }, { "type": [ "h-area" ], "properties": {} } ] } ], "rels": {}, "rel-urls": {} }|] it "does not allow html in text nodes" $ do -- there was a bug where <script> would become <script></script>'|] `shouldBe` [json|{ "items": [ { "type": [ "h-entry" ], "properties": { "content": [ { "value": "hello '<script></script>'", "html": "hello '<script></script>'" } ] } } ], "rels": {}, "rel-urls": {} }|] it "inserts value and html into e-* h-* properties" $ do parseMf2' [xml|