@@ -0,0 +1,53 @@
1+--------------------------------------------------------------------------------
2+module Hakyll.Core.Provider.Metadata.Tests
3+ ( tests
4+ ) where
5+
6+
7+--------------------------------------------------------------------------------
8+import Test.Framework (Test, testGroup)
9+import Test.HUnit (Assertion, (@=?))
10+import Text.Parsec as P
11+import Text.Parsec.String (Parser)
12+
13+
14+--------------------------------------------------------------------------------
15+import Hakyll.Core.Provider.Metadata
16+import TestSuite.Util
17+
18+
19+--------------------------------------------------------------------------------
20+tests :: Test
21+tests = testGroup "Hakyll.Core.Provider.Metadata.Tests" $
22+ fromAssertions "page" [testPage01, testPage02]
23+
24+
25+--------------------------------------------------------------------------------
26+testPage01 :: Assertion
27+testPage01 = testParse page ([("foo", "bar")], "qux\n")
28+ "---\n\
29+ \foo: bar\n\
30+ \---\n\
31+ \qux\n"
32+
33+
34+--------------------------------------------------------------------------------
35+testPage02 :: Assertion
36+testPage02 = testParse page
37+ ([("description", descr)], "Hello I am dog\n")
38+ "---\n\
39+ \description: A long description that would look better if it\n\
40+ \ spanned multiple lines and was indented\n\
41+ \---\n\
42+ \Hello I am dog\n"
43+ where
44+ descr =
45+ "A long description that would look better if it \
46+ \spanned multiple lines and was indented"
47+
48+
49+--------------------------------------------------------------------------------
50+testParse :: (Eq a, Show a) => Parser a -> a -> String -> Assertion
51+testParse parser expected input = case P.parse parser "<inline>" input of
52+ Left err -> error $ show err
53+ Right x -> expected @=? x