on master help sign in
Added some unit tests for CompressCss
commit66a90395fc1174d05254876d11698f4de5a895c2 authorNicole Rauch <nicole.m@gmx.de> dateSat 13 Aug 2016, 22:11 (10 years ago) parentfdb298d
3 files changed+46
hakyll.cabal+1 tests/Hakyll/Web/CompressCss/Tests.hs+43 tests/TestSuite.hs+2
hakyll.cabal+1
@@ -223,6 +223,7 @@ Test-suite hakyll-tests
223223 Hakyll.Core.Store.Tests
224224 Hakyll.Core.UnixFilter.Tests
225225 Hakyll.Core.Util.String.Tests
226+ Hakyll.Web.CompressCss.Tests
226227 Hakyll.Web.Html.RelativizeUrls.Tests
227228 Hakyll.Web.Html.Tests
228229 Hakyll.Web.Pandoc.FileType.Tests
tests/Hakyll/Web/CompressCss/Tests.hsnew file+43
@@ -0,0 +1,43 @@
1+--------------------------------------------------------------------------------
2+module Hakyll.Web.CompressCss.Tests
3+ ( tests
4+ ) where
5+
6+
7+--------------------------------------------------------------------------------
8+import Data.Char (toUpper)
9+import Test.Framework (Test, testGroup)
10+import Test.HUnit (assert, (@=?))
11+
12+
13+--------------------------------------------------------------------------------
14+import Hakyll.Web.CompressCss
15+import TestSuite.Util
16+
17+
18+--------------------------------------------------------------------------------
19+tests :: Test
20+tests = testGroup "Hakyll.Web.CompressCss.Tests" $ concat
21+ [ fromAssertions "compressCss"
22+ [
23+ -- compress whitespace
24+ " something something " @=?
25+ compressCss " something \n\t\r something "
26+
27+ -- strip comments
28+ , "" @=?
29+ compressCss "/* abc { } ;; \n\t\r */"
30+
31+ -- compress separators
32+ , "}" @=?
33+ compressCss "; }"
34+ , "{};" @=?
35+ compressCss " { } ; "
36+ , ";" @=?
37+ compressCss ";;;;;;;"
38+
39+ -- some real-life css
40+ , "a:after{content: \" (\" attr(href) \")\"}" @=?
41+ compressCss "a:after { content: \" (\" attr(href) \")\"; }"
42+ ]
43+ ]
tests/TestSuite.hs+2
@@ -19,6 +19,7 @@ import qualified Hakyll.Core.Runtime.Tests
1919import qualified Hakyll.Core.Store.Tests
2020import qualified Hakyll.Core.UnixFilter.Tests
2121import qualified Hakyll.Core.Util.String.Tests
22+import qualified Hakyll.Web.CompressCss.Tests
2223import qualified Hakyll.Web.Html.RelativizeUrls.Tests
2324import qualified Hakyll.Web.Html.Tests
2425import qualified Hakyll.Web.Pandoc.FileType.Tests
@@ -39,6 +40,7 @@ main = defaultMain
3940 , Hakyll.Core.Store.Tests.tests
4041 , Hakyll.Core.UnixFilter.Tests.tests
4142 , Hakyll.Core.Util.String.Tests.tests
43+ , Hakyll.Web.CompressCss.Tests.tests
4244 , Hakyll.Web.Html.RelativizeUrls.Tests.tests
4345 , Hakyll.Web.Html.Tests.tests
4446 , Hakyll.Web.Pandoc.FileType.Tests.tests