From 66a90395fc1174d05254876d11698f4de5a895c2 Mon Sep 17 00:00:00 2001 From: Nicole Rauch Date: Sat, 13 Aug 2016 22:11:56 +0200 Subject: Added some unit tests for CompressCss --- tests/Hakyll/Web/CompressCss/Tests.hs | 43 +++++++++++++++++++++++++++++++++++ tests/TestSuite.hs | 2 ++ 2 files changed, 45 insertions(+) create mode 100644 tests/Hakyll/Web/CompressCss/Tests.hs (limited to 'tests') diff --git a/tests/Hakyll/Web/CompressCss/Tests.hs b/tests/Hakyll/Web/CompressCss/Tests.hs new file mode 100644 index 0000000..1430abf --- /dev/null +++ b/tests/Hakyll/Web/CompressCss/Tests.hs @@ -0,0 +1,43 @@ +-------------------------------------------------------------------------------- +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 " + + -- strip comments + , "" @=? + compressCss "/* abc { } ;; \n\t\r */" + + -- compress separators + , "}" @=? + compressCss "; }" + , "{};" @=? + compressCss " { } ; " + , ";" @=? + compressCss ";;;;;;;" + + -- some real-life css + , "a:after{content: \" (\" attr(href) \")\"}" @=? + compressCss "a:after { content: \" (\" attr(href) \")\"; }" + ] + ] 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 -- cgit v1.2.3