diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-11-27 16:10:45 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-11-27 16:10:45 +0100 |
commit | db45ea9d8cb8fd199de2239b6bc28aff3ad53cce (patch) | |
tree | 61a4345cb0cb9d7130d5f041753bc68f80a45674 /tests/Hakyll/Web/Template/Context | |
parent | 1bcce776e786eb6688bace653ecafa1a5a4fb563 (diff) | |
download | hakyll-db45ea9d8cb8fd199de2239b6bc28aff3ad53cce.tar.gz |
Allow arbitrary keys, update some tests
Diffstat (limited to 'tests/Hakyll/Web/Template/Context')
-rw-r--r-- | tests/Hakyll/Web/Template/Context/Tests.hs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/Hakyll/Web/Template/Context/Tests.hs b/tests/Hakyll/Web/Template/Context/Tests.hs new file mode 100644 index 0000000..f2fb42a --- /dev/null +++ b/tests/Hakyll/Web/Template/Context/Tests.hs @@ -0,0 +1,51 @@ +-------------------------------------------------------------------------------- +{-# LANGUAGE OverloadedStrings #-} +module Hakyll.Web.Template.Context.Tests + ( tests + ) where + + +-------------------------------------------------------------------------------- +import Test.Framework (Test, testGroup) +import Test.Framework.Providers.HUnit (testCase) +import Test.HUnit (Assertion, (@=?)) + + +-------------------------------------------------------------------------------- +import Hakyll.Core.Compiler +import Hakyll.Core.Identifier +import Hakyll.Core.Provider +import Hakyll.Core.Store (Store) +import Hakyll.Web.Template.Context +import TestSuite.Util + + +-------------------------------------------------------------------------------- +tests :: Test +tests = testGroup "Hakyll.Core.Template.Context.Tests" + [ testCase "testDateField" testDateField + ] + + +-------------------------------------------------------------------------------- +testDateField :: Assertion +testDateField = withTestStore $ \store -> do + provider <- newTestProvider store + + date1 <- testContextDone store provider "example.md" "date" $ + dateField "date" "%B %e, %Y" + date1 @=? "October 22, 2012" + + date2 <- testContextDone store provider + "posts/2010-08-26-birthday.md" "date" $ + dateField "date" "%B %e, %Y" + date2 @=? "August 26, 2010" + + +-------------------------------------------------------------------------------- +testContextDone :: Store -> Provider -> Identifier -> String + -> Context String -> IO String +testContextDone store provider identifier key context = + testCompilerDone store provider identifier $ do + item <- getResourceBody + unContext context key item |