Debian Codegraph @

tests/Hakyll/Web/CompressCss/Tests.hs

raw
1 --------------------------------------------------------------------------------
2 module Hakyll.Web.CompressCss.Tests
3 ( tests
4 ) where
5
6
7 --------------------------------------------------------------------------------
8 import Test.Tasty (TestTree, testGroup)
9 import Test.Tasty.HUnit ((@=?))
10
11
12 --------------------------------------------------------------------------------
13 import Hakyll.Web.CompressCss
14 import TestSuite.Util
15
16
17 --------------------------------------------------------------------------------
18 tests :: TestTree
19 tests = testGroup "Hakyll.Web.CompressCss.Tests" $ concat
20 [ fromAssertions "compressCss"
21 [
22 -- compress whitespace
23 "something something" @=?
24 compressCss " something \n\t\r something "
25 -- do not compress whitespace in string tokens
26 , "abc \" \t\n\r \" xyz" @=?
27 compressCss "abc \" \t\n\r \" xyz"
28 , "abc ' \t\n\r ' xyz" @=?
29 compressCss "abc ' \t\n\r ' xyz"
30
31 -- strip comments
32 , "before after" @=? compressCss "before /* abc { } ;; \n\t\r */ after"
33 -- don't strip comments inside string tokens
34 , "before \"/* abc { } ;; \n\t\r */\" after"
35 @=? compressCss "before \"/* abc { } ;; \n\t\r */\" after"
36
37 -- compress separators
38 , "}" @=? compressCss "; }"
39 , ";{};" @=? compressCss " ; { } ; "
40 , "text," @=? compressCss "text , "
41 , "a>b" @=? compressCss "a > b"
42 , "a+b" @=? compressCss "a + b"
43 , "a!b" @=? compressCss "a ! b"
44 -- compress calc()
45 , "calc(1px + 100%/(5 + 3) - (3px + 2px)*5)" @=? compressCss "calc( 1px + 100% / ( 5 + 3) - calc( 3px + 2px ) * 5 )"
46 -- compress clamp() (issue #1021)
47 , "clamp(2.25rem, 2vw + 1.5rem, 3.25rem)" @=? compressCss "clamp(2.25rem, 2vw + 1.5rem, 3.25rem)"
48 -- compress whitespace even after this curly brace
49 , "}" @=? compressCss "; } "
50 -- but do not compress separators inside string tokens
51 , "\" { } ; , \"" @=? compressCss "\" { } ; , \""
52 -- don't compress separators at the start or end of string tokens
53 , "\" }\"" @=? compressCss "\" }\""
54 , "\"{ \"" @=? compressCss "\"{ \""
55 -- don't get irritated by the wrong token delimiter
56 , "\" ' \"" @=? compressCss "\" ' \""
57 , "' \" '" @=? compressCss "' \" '"
58 -- don't compress whitespace in the middle of a string
59 , "abc '{ '" @=? compressCss "abc '{ '"
60 , "abc \"{ \"" @=? compressCss "abc \"{ \""
61 -- compress whitespace after colons (but not before)
62 , "abc :xyz" @=? compressCss "abc : xyz"
63 -- compress multiple semicolons
64 , ";" @=? compressCss ";;;;;;;"
65 ]
66 ]