2021-04-05 21:45:18 +02:00
|
|
|
module XML.Favicon (
|
|
|
|
test
|
|
|
|
) where
|
|
|
|
|
|
|
|
import Blog.Skin (findImage)
|
|
|
|
import Distribution.TestSuite
|
2021-05-02 16:49:05 +02:00
|
|
|
import Mock.URL (cdnFavicon, hostFavicon, localDiscovered, localFavicon)
|
2021-04-05 21:45:18 +02:00
|
|
|
import Network.URL (URL)
|
2021-05-02 16:49:05 +02:00
|
|
|
import System.Directory (withCurrentDirectory)
|
|
|
|
import Utils (assertAll, assertEqual, simpleTest, tag, testDataPath)
|
2021-04-05 21:45:18 +02:00
|
|
|
|
|
|
|
check :: IO (Maybe URL) -> Maybe URL -> IO Progress
|
2021-05-02 16:49:05 +02:00
|
|
|
check getter expected =
|
|
|
|
withCurrentDirectory (testDataPath "XML/Favicon/Input") $ do
|
|
|
|
actual <- getter
|
|
|
|
assertAll $ [
|
|
|
|
assertEqual "URLs" actual expected
|
|
|
|
]
|
2021-04-05 21:45:18 +02:00
|
|
|
|
|
|
|
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))
|
2021-05-02 16:49:05 +02:00
|
|
|
, ("manual host-relative", check (findImage "" (Just "/favicon.png")) (Just hostFavicon))
|
2021-04-17 17:19:17 +02:00
|
|
|
, ("manual relative", check (findImage "" (Just "favicon.png")) (Just localFavicon))
|
2021-04-05 21:45:18 +02:00
|
|
|
]
|