|]
mockFetch "http://author/page" = return $ Just [xml|Author from Page!|]
mockFetch _ = return Nothing
rE u = let mf = parseMf2 def . documentRoot . parseLBS . fromMaybe "" . runIdentity $ mockFetch u in
runIdentity . entryAuthors def mockFetch u mf . head . fromJust $ allMicroformatsOfType "h-entry" mf
card n = o [ "value" .= String n
, "type" .= [ String "h-card" ]
, "properties" .= o [ "name" .= [ String n ] ] ]
card' n = o [ "type" .= [ String "h-card" ]
, "properties" .= o [ "name" .= [ String n ] ] ]
it "finds the author h-cards embedded in the h-entry" $ do
rE "http://direct" `shouldBe` Just [ card "Author from Direct!" ]
it "finds the author h-cards embedded in the h-feed parent of h-entry" $ do
rE "http://feed" `shouldBe` Just [ card "Author from Feed!" ]
it "finds the author h-cards linked from the h-entry" $ do
rE "http://link" `shouldBe` Just [ card' "Author from Page!" ]
it "finds the author h-cards linked from the h-feed parent of h-entry" $ do
rE "http://feed/link" `shouldBe` Just [ card' "Author from Page!" ]
it "finds the author h-cards linked as rel=author" $ do
rE "http://rel" `shouldBe` Just [ card' "Author from Page!" ]
rE "http://author/page/link-relative" `shouldBe` Just [ card' "Author from Page!" ]