summaryrefslogtreecommitdiff
path: root/tests/Hakyll/Web/CompressCss/Tests.hs
blob: 7420e4c6d14b9c9dbcc3bd54c56599fa15e1f92d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
--------------------------------------------------------------------------------
module Hakyll.Web.CompressCss.Tests
    ( tests
    ) where


--------------------------------------------------------------------------------
import           Data.Char              (toUpper)
import           Test.Tasty             (TestTree, testGroup)
import           Test.Tasty.HUnit       (assert, (@=?))


--------------------------------------------------------------------------------
import           Hakyll.Web.CompressCss
import           TestSuite.Util


--------------------------------------------------------------------------------
tests :: TestTree
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 " ;  {  }  ;  "
        , "text,"         @=? compressCss "text  ,  "
        , "a>b"           @=? compressCss "a > b"
        , "a+b"           @=? compressCss "a + b"
        , "a!b"           @=? compressCss "a ! b"
          -- 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 around colons
        , "abc:xyz"       @=? compressCss "abc : xyz"
          -- compress multiple semicolons
        , ";"             @=? compressCss ";;;;;;;"
        ]
    ]