From cf138a415b0fbfa5153deec693f1310547f359b2 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Mon, 6 May 2013 23:32:25 +0200 Subject: Implement foreach structure --- tests/Hakyll/Web/Template/Context/Tests.hs | 7 ++++++- tests/Hakyll/Web/Template/Tests.hs | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'tests/Hakyll/Web/Template') diff --git a/tests/Hakyll/Web/Template/Context/Tests.hs b/tests/Hakyll/Web/Template/Context/Tests.hs index 5533c71..627624f 100644 --- a/tests/Hakyll/Web/Template/Context/Tests.hs +++ b/tests/Hakyll/Web/Template/Context/Tests.hs @@ -51,4 +51,9 @@ testContextDone :: Store -> Provider -> Identifier -> String testContextDone store provider identifier key context = testCompilerDone store provider identifier $ do item <- getResourceBody - unContext context key item + cf <- unContext context key item + case cf of + StringField str -> return str + ListField _ _ -> error $ + "Hakyll.Web.Template.Context.Tests.testContextDone: " ++ + "Didn't expect ListField" diff --git a/tests/Hakyll/Web/Template/Tests.hs b/tests/Hakyll/Web/Template/Tests.hs index b96cfa5..1d80a06 100644 --- a/tests/Hakyll/Web/Template/Tests.hs +++ b/tests/Hakyll/Web/Template/Tests.hs @@ -13,6 +13,7 @@ import Test.HUnit (Assertion, (@=?), (@?=)) -------------------------------------------------------------------------------- +import Hakyll.Core.Compiler import Hakyll.Core.Item import Hakyll.Core.Provider import Hakyll.Web.Pandoc @@ -43,6 +44,8 @@ case01 = do item <- testCompilerDone store provider "example.md" $ pandocCompiler >>= applyTemplate (itemBody tpl) testContext + writeFile "foo" (itemBody item) + out @=? itemBody item cleanTestEnv @@ -50,9 +53,13 @@ case01 = do -------------------------------------------------------------------------------- testContext :: Context String testContext = mconcat - [ functionField "echo" (\args _ -> return $ unwords args) - , defaultContext + [ defaultContext + , listField "authors" (bodyField "name") $ do + n1 <- makeItem "Jan" + n2 <- makeItem "Piet" + return [n1, n2] ] + where -------------------------------------------------------------------------------- -- cgit v1.2.3