From 002cf4de32db979d515c2a9cdcd8c8f42859a797 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Wed, 9 Feb 2011 18:11:24 +0100 Subject: Add hamlet templates and restructure tests --- tests/Hakyll/Web/Template/Tests.hs | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/Hakyll/Web/Template/Tests.hs (limited to 'tests/Hakyll/Web/Template') diff --git a/tests/Hakyll/Web/Template/Tests.hs b/tests/Hakyll/Web/Template/Tests.hs new file mode 100644 index 0000000..d95b151 --- /dev/null +++ b/tests/Hakyll/Web/Template/Tests.hs @@ -0,0 +1,46 @@ +{-# LANGUAGE OverloadedStrings #-} +module Hakyll.Web.Template.Tests + ( tests + ) where + +import Test.Framework +import Test.Framework.Providers.HUnit +import Test.HUnit hiding (Test) + +import qualified Data.Map as M + +import Hakyll.Web.Page +import Hakyll.Web.Template +import Hakyll.Web.Template.Read.Hakyll +import Hakyll.Web.Template.Read.Hamlet +import TestSuite.Util + +tests :: [Test] +tests = fromAssertions "applyTemplate" + -- Hakyll templates + [ applyTemplateAssertion readTemplate + "bar" "$foo$" [("foo", "bar")] + + , applyTemplateAssertion readTemplate + "$ barqux" "$$ $foo$$bar$" [("foo", "bar"), ("bar", "qux")] + + -- Hamlet templates + , applyTemplateAssertion readHamletTemplate + "noticeA paragraph" + "#{title}\n\ + \ Template) -- ^ Template parser + -> String -- ^ Expected + -> String -- ^ Template + -> [(String, String)] -- ^ Page + -> Assertion -- ^ Resulting assertion +applyTemplateAssertion parser expected template page = + expected @=? pageBody (applyTemplate (parser template) + (fromMap $ M.fromList page)) -- cgit v1.2.3