on master help sign in
Added some tests for the date rendering.
commit6c1d41dbe2969988e8ad648184429657bbc3cb3b authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSun 3 Jan 2010, 16:01 (17 years ago) parent1fdffc6
1 file changed+21
tests/Tests.hs+21
tests/Tests.hs+21
@@ -5,9 +5,12 @@ import Test.QuickCheck
55import Test.HUnit
66
77import Data.Char
8+import qualified Data.Map as M
9+import qualified Data.ByteString.Lazy.Char8 as B
810
911import Text.Hakyll.CompressCSS
1012import Text.Hakyll.Util
13+import Text.Hakyll.Context
1114
1215main = defaultMain tests
1316
@@ -26,6 +29,10 @@ tests = [ testGroup "Util group" [ testProperty "trim length" prop_trim_length
2629 , testCase "compressCSS 2" test_compress_css2
2730 , testCase "compressCSS 3" test_compress_css3
2831 ]
32+
33+ , testGroup "Context group" [ testCase "renderDate 1" test_render_date1
34+ , testCase "renderDate 2" test_render_date1
35+ ]
2936 ]
3037
3138-- Test that a string always becomes shorter when trimmed.
@@ -57,3 +64,17 @@ prop_compress_css_length str = length str >= length (compressCSS str)
5764test_compress_css1 = compressCSS "a { \n color : red; }" @?= "a{color:red}"
5865test_compress_css2 = compressCSS "img {border :none;;;; }" @?= "img{border:none}"
5966test_compress_css3 = compressCSS "p {font-size : 90%;} h1 {color :white;;; }" @?= "p{font-size:90%}h1{color:white}"
67+
68+-- Date rendering test cases.
69+test_render_date1 = M.lookup (B.pack "date") rendered @?= Just (B.pack "December 30, 2009")
70+ where rendered = renderDate "date"
71+ "%B %e, %Y"
72+ "Unknown date"
73+ (M.singleton (B.pack "path")
74+ (B.pack "2009-12-30-a-title.markdown"))
75+test_render_date2 = M.lookup (B.pack "date") rendered @?= Just (B.pack "Unknown date")
76+ where rendered = renderDate "date"
77+ "%B %e, %Y"
78+ "Unknown date"
79+ (M.singleton (B.pack "path")
80+ (B.pack "2009-badness-30-a-title.markdown"))