hakyll/tests/Hakyll/Core/Provider/Metadata/Tests.hs

55 lines
1.8 KiB
Haskell
Raw Normal View History

2013-02-26 18:20:55 +00:00
--------------------------------------------------------------------------------
module Hakyll.Core.Provider.Metadata.Tests
( tests
) where
--------------------------------------------------------------------------------
2016-04-06 12:26:46 +00:00
import qualified Data.HashMap.Strict as HMS
import qualified Data.Text as T
import qualified Data.Yaml as Yaml
import Hakyll.Core.Metadata
import Hakyll.Core.Provider.Metadata
2013-02-26 18:20:55 +00:00
import Test.Framework (Test, testGroup)
import Test.HUnit (Assertion, (@=?))
import TestSuite.Util
--------------------------------------------------------------------------------
tests :: Test
tests = testGroup "Hakyll.Core.Provider.Metadata.Tests" $
fromAssertions "page" [testPage01, testPage02]
2016-04-06 12:26:46 +00:00
2013-02-26 18:20:55 +00:00
--------------------------------------------------------------------------------
testPage01 :: Assertion
2016-04-06 12:26:46 +00:00
testPage01 =
Right (meta [("foo", "bar")], "qux\n") @=? parsePage
2013-02-26 18:20:55 +00:00
"---\n\
\foo: bar\n\
\---\n\
\qux\n"
--------------------------------------------------------------------------------
testPage02 :: Assertion
2016-04-06 12:26:46 +00:00
testPage02 =
Right (meta [("description", descr)], "Hello I am dog\n") @=?
parsePage
2013-02-26 18:20:55 +00:00
"---\n\
\description: A long description that would look better if it\n\
\ spanned multiple lines and was indented\n\
\---\n\
\Hello I am dog\n"
where
2016-04-06 12:26:46 +00:00
descr :: String
2013-02-26 18:20:55 +00:00
descr =
"A long description that would look better if it \
\spanned multiple lines and was indented"
--------------------------------------------------------------------------------
2016-04-06 12:26:46 +00:00
meta :: Yaml.ToJSON a => [(String, a)] -> Metadata
meta pairs = HMS.fromList [(T.pack k, Yaml.toJSON v) | (k, v) <- pairs]