]> Git — Sourcephile - webc.git/blob - tests/HUnits.hs
init
[webc.git] / tests / HUnits.hs
1 {-# LANGUAGE OverloadedStrings #-}
2
3 module HUnits where
4
5 import Data.Tree
6 import Network.URI.Slug
7 import Relude
8 import Test.Tasty
9 import Test.Tasty.HUnit
10
11 import Examples.E01 qualified as E01
12 import Webc
13
14 test :: TestTree
15 test =
16 testGroup
17 "HUnits"
18 [ testGroup
19 "Encoder"
20 [ testEncoder
21 "E01"
22 E01.site
23 [ (E01.Index, ["index.html"])
24 , (E01.About, ["about.html"])
25 ]
26 ]
27 , testGroup
28 "Layouter"
29 [ testLayouter
30 "E01"
31 E01.site
32 [
33 [ Node (LayoutNodeSlug "index.html") []
34 , Node (LayoutNodeSlug "about.html") []
35 , Node (LayoutNodeSlug "contact.html") []
36 ]
37 ]
38 ]
39 ]
40 where
41 testEncoder :: String -> Encoder a -> [(a, [Slug])] -> TestTree
42 testEncoder ex site as =
43 testGroup ex $
44 zipWith
45 (\n (a, expected) -> testCase n $ encode site a @?= expected)
46 (show <$> [1 :: Int ..])
47 as
48 testLayouter :: Eq a => Show a => String -> Layouter a -> [Forest LayoutNode] -> TestTree
49 testLayouter ex site as =
50 testGroup ex $
51 zipWith
52 (\n expected -> testCase n $ layout site @?= expected)
53 (show <$> [1 :: Int ..])
54 as