summaryrefslogtreecommitdiff
path: root/tests/Hakyll/Web/Page
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-03-29 18:19:19 +0200
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-03-29 18:19:19 +0200
commit379cd0eed48848ddf67c3de4def4f807372e713c (patch)
treea231b3b81609602b25250f2b16df76834705fa5a /tests/Hakyll/Web/Page
parent8bd45b97dec932cf3814c68913693f2aefaac18f (diff)
downloadhakyll-379cd0eed48848ddf67c3de4def4f807372e713c.tar.gz
Add copyBodyToField, copyBodyFromField methods
Diffstat (limited to 'tests/Hakyll/Web/Page')
-rw-r--r--tests/Hakyll/Web/Page/Metadata/Tests.hs54
1 files changed, 54 insertions, 0 deletions
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")
+ ]
+ ]