MCPcopy Create free account
hub / github.com/tdewolff/minify / TestCSS

Function TestCSS

css/css_test.go:14–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestCSS(t *testing.T) {
15 cssTests := []struct {
16 css string
17 expected string
18 }{
19 {"/*comment*/", ""},
20 {"/*! bang comment */", "/*!bang comment*/"},
21 {"/*# sourceMappingURL=url */", ""},
22 {"a;", "a"},
23 {"i{a:b;}/*! bang comment */", "i{a:b}/*!bang comment*/"},
24 {"i { key: value; key2: value; }", "i{key:value;key2:value}"},
25 {".cla .ss > #id { x:y; }", ".cla .ss>#id{x:y}"},
26 {".cla[id ^= L] { x:y; }", ".cla[id^=L]{x:y}"},
27 {"area:focus { outline : 0;}", "area:focus{outline:0}"},
28 {"@import 'file';", "@import 'file'"},
29 {"@import url('file');", "@import 'file'"},
30 {"@import url(//url);", `@import "//url"`},
31 {"@import url(\n//url\n);", `@import "//url"`},
32 {"@import url();", `@import ""`},
33 {"@font-face { x:y; }", "@font-face{x:y}"},
34
35 {"input[type=\"radio\"]{x:y}", "input[type=radio]{x:y}"},
36 {"input[type=\"radio\" i]{x:y}", "input[type=radio i]{x:y}"},
37 {"DIV{margin:1em}", "div{margin:1em}"},
38 {".CLASS{margin:1em}", ".CLASS{margin:1em}"},
39 {"@MEDIA all{a:b}", "@media all{a:b}"},
40 {"@media only screen and (max-width : 800px){a:b}", "@media only screen and (max-width:800px){a:b}"},
41 {"@media (-webkit-min-device-pixel-ratio:1.5),(min-resolution:1.5dppx){a:b}", "@media(-webkit-min-device-pixel-ratio:1.5),(min-resolution:1.5dppx){a:b}"},
42 {"[class^=icon-] i[class^=icon-],i[class*=\" icon-\"]{x:y}", "[class^=icon-] i[class^=icon-],i[class*=\" icon-\"]{x:y}"},
43 {"html{line-height:1;}html{line-height:1;}", "html{line-height:1}html{line-height:1}"},
44 {"a { b: 1", "a{b:1}"},
45 {"@unknown { border:1px solid #000 }", "@unknown{border:1px solid #000 }"},
46 {":root { --custom-variable:0px; }", ":root{--custom-variable:0px}"},
47 {"a, b, c {color:red}", "a,b,c{color:red}"},
48 {"a, b, c { /* lala */ }", ""},
49
50 // recurring property overwrites previous
51 //{"a{color:blue;color:red}", "a{color:red}"},
52 //{"a{unknownprop:blue;unknownprop:red}", "a{unknownprop:red}"},
53 //{"a{unknownprop:blue;otherunknownprop:red}", "a{unknownprop:blue;otherunknownprop:red}"},
54 //{"a{background-color:blue;background:0 0}", "a{background:0 0}"},
55 //{"a{color:blue}a{color:red}", "a{color:blue}a{color:red}"}, // not supported
56
57 // case sensitivity
58 {"@counter-style Ident{a:b}", "@counter-style Ident{a:b}"},
59
60 // coverage
61 {"a, b + c { x:y; }", "a,b+c{x:y}"},
62
63 // bad declaration
64 {".clearfix { *zoom: 1px; }", ".clearfix{*zoom:1px}"},
65 {".clearfix { *zoom: 1px }", ".clearfix{*zoom:1px}"},
66 {".clearfix { order:4; *zoom: 1px; color:red; }", ".clearfix{order:4;*zoom:1px;color:red}"},
67
68 // go-fuzz
69 {"input[type=\"\x00\"] { a: b\n}.a{b:c}", "input[type=\"\x00\"]{a:b}.a{b:c}"},
70 {"a{a:)'''", "a{a:)'''}"},
71 {"{T:l(", "{t:l()}"},

Callers

nothing calls this directly

Calls 4

RunMethod · 0.80
MinifyFunction · 0.70
MinifyMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…