{-# LANGUAGE OverloadedStrings, UnicodeSyntax, QuasiQuotes, CPP #-} module Data.Microformats2.Parser.InternalSpec (spec) where import Test.Hspec import TestCommon import Text.HTML.DOM import Text.XML.Lens (documentRoot) import Data.Microformats2.Parser.Internal #if __GLASGOW_HASKELL__ < 709 import Control.Applicative #endif {-# ANN module ("HLint: ignore Redundant do"::String) #-} spec ∷ Spec spec = do describe "extractProperty" $ do it "parses p- properties" $ do let nm = extractProperty P "name" . documentRoot . parseLBS nm [xml|
Goodbye Img!
|] `shouldBe` pure "Goodbye Img!" nm [xml|HOA
|] `shouldBe` pure "Hello Only Abbr!" nm [xml|Goodbye Abbr!
|] `shouldBe` pure "Goodbye Abbr!" nm [xml||] `shouldBe` pure "Hello Only Nested Img!" nm [xml|
Goodbye Nested Img!
|] `shouldBe` pure "Goodbye Nested Img!" nm [xml|HOA
|] `shouldBe` pure "Hello Only Nested Abbr!" nm [xml|Goodbye Nested Abbr!
|] `shouldBe` pure "Goodbye Nested Abbr!" nm [xml|Hello Text!
|] `shouldBe` pure "Hello Text!" it "parses implied u-photo" $ do let ph = implyProperty U "photo" . documentRoot . parseLBS ph [xml||] `shouldBe` pure "selfie.png" ph [xml|