on master help sign in
Some tests for the Page module
commitd9e0c3e86b03834a03e7ddf37b70cc141eccfe1c authorJasper Van der Jeugt <jaspervdj@gmail.com> dateWed 9 Feb 2011, 19:28 (16 years ago) parent002cf4d
3 files changed+39−1
src/Hakyll/Web/Page/Internal.hs+1−1 tests/Hakyll/Web/Page/Tests.hs+35 tests/TestSuite.hs+3
src/Hakyll/Web/Page/Internal.hs+1−1
@@ -20,7 +20,7 @@ import Hakyll.Core.Writable
2020data Page a = Page
2121 { pageMetadata :: Map String String
2222 , pageBody :: a
23− } deriving (Show, Typeable)
23+ } deriving (Eq, Show, Typeable)
2424
2525instance Monoid a => Monoid (Page a) where
2626 mempty = Page M.empty mempty
tests/Hakyll/Web/Page/Tests.hsnew file+35
@@ -0,0 +1,35 @@
1+{-# LANGUAGE OverloadedStrings #-}
2+module Hakyll.Web.Page.Tests
3+ ( tests
4+ ) where
5+
6+import Test.Framework
7+import Test.Framework.Providers.HUnit
8+import Test.HUnit hiding (Test)
9+
10+import qualified Data.Map as M
11+
12+import Hakyll.Web.Page
13+import Hakyll.Web.Page.Internal
14+import Hakyll.Web.Page.Read
15+import TestSuite.Util
16+
17+tests :: [Test]
18+tests = fromAssertions "applyTemplate"
19+ -- Hakyll templates
20+ [ Page (M.singleton "foo" "bar") "body\n" @=? readPage
21+ "--- \n\
22+ \foo: bar \n\
23+ \--- \n\
24+ \body"
25+
26+ , Page M.empty "line one\nlijn twee\n" @=? readPage
27+ "line one\n\
28+ \lijn twee"
29+
30+ , Page (M.fromList [("field1", "unos"), ("veld02", "deux")]) "" @=? readPage
31+ "---\n\
32+ \veld02: deux\n\
33+ \field1: unos\n\
34+ \---"
35+ ]
tests/TestSuite.hs+3
@@ -5,6 +5,7 @@ import Test.Framework (defaultMain, testGroup)
55import qualified Hakyll.Core.DirectedGraph.Tests
66import qualified Hakyll.Core.Identifier.Tests
77import qualified Hakyll.Core.Routes.Tests
8+import qualified Hakyll.Web.Page.Tests
89import qualified Hakyll.Web.Template.Tests
910
1011main :: IO ()
@@ -15,6 +16,8 @@ main = defaultMain
1516 Hakyll.Core.Identifier.Tests.tests
1617 , testGroup "Hakyll.Core.Routes.Tests"
1718 Hakyll.Core.Routes.Tests.tests
19+ , testGroup "Hakyll.Web.Page.Tests"
20+ Hakyll.Web.Page.Tests.tests
1821 , testGroup "Hakyll.Web.Template.Tests"
1922 Hakyll.Web.Template.Tests.tests
2023 ]