@@ -0,0 +1,53 @@
1+import Test.Framework (defaultMain, testGroup)
2+import Test.Framework.Providers.QuickCheck2
3+import Test.Framework.Providers.HUnit
9+import Text.Hakyll.CompressCSS
10+import Text.Hakyll.Util
12+main = defaultMain tests
14+tests = [ testGroup "Util group" [ testProperty "trim length" prop_trim_length
15+ , testProperty "trim id" prop_trim_id
16+ , testProperty "trim empty" prop_trim_empty
17+ , testCase "stripHTML 1" test_strip_html1
18+ , testCase "stripHTML 2" test_strip_html2
19+ , testCase "stripHTML 3" test_strip_html3
22+ , testGroup "CompressCSS group" [ testProperty "compressCSS length" prop_compress_css_length
23+ , testCase "compressCSS 1" test_compress_css1
24+ , testCase "compressCSS 2" test_compress_css2
25+ , testCase "compressCSS 3" test_compress_css3
29+-- Test that a string always becomes shorter when trimmed.
30+prop_trim_length str = length str >= length (trim str)
32+-- Check that a string which does not start or end with a space is not trimmed.
33+prop_trim_id str = (not $ null str)
34+ && (not $ isSpace $ head str)
35+ && (not $ isSpace $ last str)
36+ ==> str == (trim str)
38+-- An string of only spaces should be reduced to an empty string.
39+prop_trim_empty str = (all isSpace str) ==> null (trim str)
41+-- Strip HTML test cases.
42+test_strip_html1 = stripHTML "<b>text</b>" @?= "text"
43+test_strip_html2 = stripHTML "text" @?= "text"
44+test_strip_html3 = stripHTML "<b>Hakyll</b> is an <i>awesome</i> web framework <img src=\"foo.png\" />" @?=
45+ "Hakyll is an awesome web framework "
47+-- CSS compression should always decrease the text length.
48+prop_compress_css_length str = length str >= length (compressCSS str)
50+-- Compress CSS test cases.
51+test_compress_css1 = compressCSS "a { \n color : red; }" @?= "a{color:red}"
52+test_compress_css2 = compressCSS "img {border :none;;;; }" @?= "img{border:none}"
53+test_compress_css3 = compressCSS "p {font-size : 90%;} h1 {color :white;;; }" @?= "p{font-size:90%}h1{color:white}"