diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-06-20 10:45:17 +0200 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-06-20 10:45:17 +0200 |
commit | bb9ea6f1226b55a584cfcec47efeddabc230418d (patch) | |
tree | 74924cc1a3b8172906c64b50a3320f9014422cfd /tests | |
parent | 2282e78e9c9a6fd0919a13a11e070ac52cdce52f (diff) | |
download | hakyll-bb9ea6f1226b55a584cfcec47efeddabc230418d.tar.gz |
Add newtype for Context
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Page.hs | 16 | ||||
-rw-r--r-- | tests/Template.hs | 8 |
2 files changed, 15 insertions, 9 deletions
diff --git a/tests/Page.hs b/tests/Page.hs index 1b80578..d12638e 100644 --- a/tests/Page.hs +++ b/tests/Page.hs @@ -35,7 +35,8 @@ test_readPage fileName content assertion = do temporaryDir <- getTemporaryDirectory let temporaryFile = temporaryDir </> fileName writeFile temporaryFile content - page <- runReaderT (readPage temporaryFile) defaultHakyllConfiguration + page <- runReaderT (readPage temporaryFile) + (defaultHakyllConfiguration "http://examples.com") removeFile temporaryFile return $ assertion page @@ -48,7 +49,7 @@ test_readPage_1 = test_readPage fileName content assertion @? "test_readPage_1" , "---" , "This is a simple test." ] - assertion page = M.lookup "author" page == Just "Eric Cartman" + assertion page = M.lookup "author" (unContext page) == Just "Eric Cartman" -- | readPage test case 2. test_readPage_2 = test_readPage fileName content assertion @? "test_readPage_2" @@ -59,8 +60,10 @@ test_readPage_2 = test_readPage fileName content assertion @? "test_readPage_2" , "---" , "This is the body." ] - assertion page = M.lookup "someSection" page == Just "This is a section.\n" - && M.lookup "body" page == Just "This is the body.\n" + assertion page = + let m = unContext page + in M.lookup "someSection" m == Just "This is a section.\n" + && M.lookup "body" m == Just "This is the body.\n" -- | readPage test case 3. test_readPage_3 = test_readPage fileName content assertion @? "test_readPage_3" @@ -68,7 +71,8 @@ test_readPage_3 = test_readPage fileName content assertion @? "test_readPage_3" fileName = "test_readPage_3.txt" content = unlines [ "No metadata here, sorry." ] - assertion page = M.lookup "body" page == Just "No metadata here, sorry.\n" + assertion page = + M.lookup "body" (unContext page) == Just "No metadata here, sorry.\n" -- | readPage test case 4. test_readPage_4 = test_readPage fileName content assertion @? "test_readPage_4" @@ -81,7 +85,7 @@ test_readPage_4 = test_readPage fileName content assertion @? "test_readPage_4" , "------" , "The header is not a separate section." ] - assertion page = M.lookup "body" page == Just body + assertion page = M.lookup "body" (unContext page) == Just body body = unlines [ "Header" , "------" , "The header is not a separate section." diff --git a/tests/Template.hs b/tests/Template.hs index 9924efb..4024b6a 100644 --- a/tests/Template.hs +++ b/tests/Template.hs @@ -5,6 +5,7 @@ module Template import qualified Data.Map as M import Control.Applicative ((<$>)) import Control.Monad (replicateM) +import Data.Monoid (mempty) import Data.Binary import Test.Framework (testGroup) @@ -13,6 +14,7 @@ import Test.Framework.Providers.QuickCheck2 import Test.HUnit import Test.QuickCheck +import Text.Hakyll.Context (Context (..)) import Text.Hakyll.Internal.Template -- Template test group. @@ -58,18 +60,18 @@ prop_template_encode_id template = decode (encode template) == template -- Check we get the same sting with empty substitutions. prop_substitute_id string = - regularSubstitute (fromString string) M.empty == string + regularSubstitute (fromString string) mempty == string -- substitute test case 1. test_substitute_1 = finalSubstitute template context @?= "Banana costs $4." where template = fromString "$product costs $$$price." - context = M.fromList [("product", "Banana"), ("price", "4")] + context = Context $ M.fromList [("product", "Banana"), ("price", "4")] -- substitute test case 2. test_substitute_2 = regularSubstitute template context @?= "$$root is a special key." where template = fromString "$$root is a special $thing." - context = M.fromList [("root", "foo"), ("thing", "key")] + context = Context $ M.fromList [("root", "foo"), ("thing", "key")] |