{-# LANGUAGE OverloadedStrings #-} module HUnits where import Data.Tree import Network.URI.Slug import Relude import Test.Tasty import Test.Tasty.HUnit import Examples.E01 qualified as E01 import Webc test :: TestTree test = testGroup "HUnits" [ testGroup "Encoder" [ testEncoder "E01" E01.site [ (E01.Index, ["index.html"]) , (E01.About, ["about.html"]) ] ] , testGroup "Layouter" [ testLayouter "E01" E01.site [ [ Node (LayoutNodeSlug "index.html") [] , Node (LayoutNodeSlug "about.html") [] , Node (LayoutNodeSlug "contact.html") [] ] ] ] ] where testEncoder :: String -> Encoder a -> [(a, [Slug])] -> TestTree testEncoder ex site as = testGroup ex $ zipWith (\n (a, expected) -> testCase n $ encode site a @?= expected) (show <$> [1 :: Int ..]) as testLayouter :: Eq a => Show a => String -> Layouter a -> [Forest LayoutNode] -> TestTree testLayouter ex site as = testGroup ex $ zipWith (\n expected -> testCase n $ layout site @?= expected) (show <$> [1 :: Int ..]) as