module XML.Favicon ( test ) where import Blog.Skin (findImage) import Distribution.TestSuite import Mock.URL (cdnFavicon, hostFavicon, localDiscovered, localFavicon) import Network.URL (URL) import System.Directory (withCurrentDirectory) import Utils (assertAll, assertEqual, simpleTest, tag, testDataPath) check :: IO (Maybe URL) -> Maybe URL -> IO Progress check getter expected = withCurrentDirectory (testDataPath "XML/Favicon/Input") $ do actual <- getter assertAll $ [ assertEqual "URLs" actual expected ] test :: Test test = tag "favicon" . testGroup "Favicons" $ simpleTest <$> [ ("auto-discover", check (findImage "favicon" Nothing) (Just localDiscovered)) , ("none", check (findImage "blerp" Nothing) Nothing) , ("manual absolute", check (findImage "" (Just "https://cdn.net/favicon.png")) (Just cdnFavicon)) , ("manual host-relative", check (findImage "" (Just "/favicon.png")) (Just hostFavicon)) , ("manual relative", check (findImage "" (Just "favicon.png")) (Just localFavicon)) ]