summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2016-10-16 10:41:34 +0200
committerGitHub <noreply@github.com>2016-10-16 10:41:34 +0200
commit9d4640b76431be46847f28ea6d167bce83500e03 (patch)
tree63fdb6cd62f5275b34cc5cf12a94fa7fd65ac65f /tests
parent32e34f435c7911f36acdf4a62eec1f56faf0b269 (diff)
parent9f850a9035c29de568fb61b9646f657f5935ab89 (diff)
downloadhakyll-9d4640b76431be46847f28ea6d167bce83500e03.tar.gz
Merge pull request #463 from NicoleRauch/master
Bugfix: CompressCss modified CSS string constants which it should not do
Diffstat (limited to 'tests')
-rw-r--r--tests/Hakyll/Web/CompressCss/Tests.hs59
-rw-r--r--tests/TestSuite.hs2
2 files changed, 61 insertions, 0 deletions
diff --git a/tests/Hakyll/Web/CompressCss/Tests.hs b/tests/Hakyll/Web/CompressCss/Tests.hs
new file mode 100644
index 0000000..b356388
--- /dev/null
+++ b/tests/Hakyll/Web/CompressCss/Tests.hs
@@ -0,0 +1,59 @@
+--------------------------------------------------------------------------------
+module Hakyll.Web.CompressCss.Tests
+ ( tests
+ ) where
+
+
+--------------------------------------------------------------------------------
+import Data.Char (toUpper)
+import Test.Framework (Test, testGroup)
+import Test.HUnit (assert, (@=?))
+
+
+--------------------------------------------------------------------------------
+import Hakyll.Web.CompressCss
+import TestSuite.Util
+
+
+--------------------------------------------------------------------------------
+tests :: Test
+tests = testGroup "Hakyll.Web.CompressCss.Tests" $ concat
+ [ fromAssertions "compressCss"
+ [
+ -- compress whitespace
+ " something something " @=?
+ compressCss " something \n\t\r something "
+ -- do not compress whitespace in constants
+ , "abc \" \t\n\r \" xyz" @=?
+ compressCss "abc \" \t\n\r \" xyz"
+ , "abc ' \t\n\r ' xyz" @=?
+ compressCss "abc ' \t\n\r ' xyz"
+
+ -- strip comments
+ , "before after" @=? compressCss "before /* abc { } ;; \n\t\r */ after"
+ -- don't strip comments inside constants
+ , "before \"/* abc { } ;; \n\t\r */\" after"
+ @=? compressCss "before \"/* abc { } ;; \n\t\r */\" after"
+
+ -- compress separators
+ , "}" @=? compressCss "; }"
+ , "{};" @=? compressCss " { } ; "
+ -- compress whitespace even after this curly brace
+ , "}" @=? compressCss "; } "
+ -- but do not compress separators inside of constants
+ , "\" { } ; \"" @=? compressCss "\" { } ; \""
+ -- don't compress separators at the start or end of constants
+ , "\" }\"" @=? compressCss "\" }\""
+ , "\"{ \"" @=? compressCss "\"{ \""
+ -- don't get irritated by the wrong constant terminator
+ , "\" ' \"" @=? compressCss "\" ' \""
+ , "' \" '" @=? compressCss "' \" '"
+ -- don't compress whitespace around separators in constants in the middle of a string
+ , "abc '{ '" @=? compressCss "abc '{ '"
+ , "abc \"{ \"" @=? compressCss "abc \"{ \""
+ -- compress whitespace after colons
+ , "abc:xyz" @=? compressCss "abc : xyz"
+ -- compress multiple semicolons
+ , ";" @=? compressCss ";;;;;;;"
+ ]
+ ]
diff --git a/tests/TestSuite.hs b/tests/TestSuite.hs
index 3622301..79eb314 100644
--- a/tests/TestSuite.hs
+++ b/tests/TestSuite.hs
@@ -19,6 +19,7 @@ import qualified Hakyll.Core.Runtime.Tests
import qualified Hakyll.Core.Store.Tests
import qualified Hakyll.Core.UnixFilter.Tests
import qualified Hakyll.Core.Util.String.Tests
+import qualified Hakyll.Web.CompressCss.Tests
import qualified Hakyll.Web.Html.RelativizeUrls.Tests
import qualified Hakyll.Web.Html.Tests
import qualified Hakyll.Web.Pandoc.FileType.Tests
@@ -39,6 +40,7 @@ main = defaultMain
, Hakyll.Core.Store.Tests.tests
, Hakyll.Core.UnixFilter.Tests.tests
, Hakyll.Core.Util.String.Tests.tests
+ , Hakyll.Web.CompressCss.Tests.tests
, Hakyll.Web.Html.RelativizeUrls.Tests.tests
, Hakyll.Web.Html.Tests.tests
, Hakyll.Web.Pandoc.FileType.Tests.tests