From 379cd0eed48848ddf67c3de4def4f807372e713c Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Tue, 29 Mar 2011 18:19:19 +0200 Subject: Add copyBodyToField, copyBodyFromField methods --- tests/Hakyll/Web/Page/Metadata/Tests.hs | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/Hakyll/Web/Page/Metadata/Tests.hs (limited to 'tests/Hakyll/Web/Page') diff --git a/tests/Hakyll/Web/Page/Metadata/Tests.hs b/tests/Hakyll/Web/Page/Metadata/Tests.hs new file mode 100644 index 0000000..6fbd89a --- /dev/null +++ b/tests/Hakyll/Web/Page/Metadata/Tests.hs @@ -0,0 +1,54 @@ +module Hakyll.Web.Page.Metadata.Tests + ( tests + ) where + +import Test.Framework +import Test.HUnit hiding (Test) + +import qualified Data.Map as M +import Data.Monoid (mempty) +import Data.Char (toLower) + +import Hakyll.Web.Page +import Hakyll.Web.Page.Metadata +import TestSuite.Util + +tests :: [Test] +tests = concat $ + [ fromAssertions "getField" + [ "bar" @=? getField "foo" (Page (M.singleton "foo" "bar") "body\n") + , "" @=? getField "foo" (Page M.empty "body") + ] + + , fromAssertions "getFieldMaybe" + [ Just "bar" @=? getFieldMaybe "foo" (Page (M.singleton "foo" "bar") "") + , Nothing @=? getFieldMaybe "foo" (Page M.empty "body") + ] + + , fromAssertions "setField" + [ (Page (M.singleton "bar" "foo") "") @=? setField "bar" "foo" mempty + , (Page (M.singleton "bar" "foo") "") @=? + setField "bar" "foo" (Page (M.singleton "bar" "qux") "") + ] + + , fromAssertions "trySetField" + [ (Page (M.singleton "bar" "foo") "") @=? trySetField "bar" "foo" mempty + , (Page (M.singleton "bar" "qux") "") @=? + trySetField "bar" "foo" (Page (M.singleton "bar" "qux") "") + ] + + , fromAssertions "setFieldA" + [ (Page (M.singleton "bar" "foo") "") @=? + setFieldA "bar" (map toLower) (mempty, "FOO") + ] + + , fromAssertions "copyBodyToField" + [ (Page (M.singleton "bar" "foo") "foo") @=? + copyBodyToField "bar" (Page M.empty "foo") + ] + + , fromAssertions "copyBodyFromField" + [ (Page (M.singleton "bar" "foo") "foo") @=? + copyBodyFromField "bar" (Page (M.singleton "bar" "foo") "qux") + ] + ] -- cgit v1.2.3