@@ -35,6 +35,97 @@ describe('options/remove-empty-rulesets', function() {
3535 assert . equal ( comb . processString ( 'a { /* comment */ }\nb {} ' ) , 'a { /* comment */ }\n ' ) ;
3636 } ) ;
3737 } ) ;
38+
39+ describe ( 'detecting the value' , function ( ) {
40+ // Helper to check the detection
41+ function should_detect ( options , a , b ) {
42+ comb . detect ( options ) ;
43+ assert . equal (
44+ JSON . stringify ( comb . processString ( a ) ) ,
45+ JSON . stringify ( b )
46+ ) ;
47+ }
48+
49+ it ( 'Should detect this option set to `true`' , function ( ) {
50+ should_detect (
51+ [ 'remove-empty-rulesets' ] ,
52+ 'a { color: red }' ,
53+ {
54+ 'remove-empty-rulesets' : true
55+ }
56+ ) ;
57+ } ) ;
58+
59+ it ( 'Should detect this option set to `false` with empty block' , function ( ) {
60+ should_detect (
61+ [ 'remove-empty-rulesets' ] ,
62+ 'a {}' ,
63+ {
64+ 'remove-empty-rulesets' : false
65+ }
66+ ) ;
67+ } ) ;
68+
69+ it ( 'Should detect this option set to `false` with block containing whitespace' , function ( ) {
70+ should_detect (
71+ [ 'remove-empty-rulesets' ] ,
72+ 'a { }' ,
73+ {
74+ 'remove-empty-rulesets' : false
75+ }
76+ ) ;
77+ } ) ;
78+
79+ it ( 'Should detect this option set to `true` with block containing comment' , function ( ) {
80+ should_detect (
81+ [ 'remove-empty-rulesets' ] ,
82+ 'a { /* Hello */ }' ,
83+ {
84+ 'remove-empty-rulesets' : true
85+ }
86+ ) ;
87+ } ) ;
88+
89+ it ( 'Should detect this option set to `true` with media query containing block' , function ( ) {
90+ should_detect (
91+ [ 'remove-empty-rulesets' ] ,
92+ '@media all and (min-width:0) { a { /* Hello */ } }' ,
93+ {
94+ 'remove-empty-rulesets' : true
95+ }
96+ ) ;
97+ } ) ;
98+
99+ it ( 'Should detect this option set to `true` with media query containing comment' , function ( ) {
100+ should_detect (
101+ [ 'remove-empty-rulesets' ] ,
102+ '@media all and (min-width:0) {/* Hello */}' ,
103+ {
104+ 'remove-empty-rulesets' : true
105+ }
106+ ) ;
107+ } ) ;
108+
109+ it ( 'Should detect this option set to `false` with empty media query' , function ( ) {
110+ should_detect (
111+ [ 'remove-empty-rulesets' ] ,
112+ '@media all and (min-width:0) {}' ,
113+ {
114+ 'remove-empty-rulesets' : false
115+ }
116+ ) ;
117+ } ) ;
118+
119+ it ( 'Should detect this option set to `false` with media query containing whitespace' , function ( ) {
120+ should_detect (
121+ [ 'remove-empty-rulesets' ] ,
122+ '@media all and (min-width:0) { \n }' ,
123+ {
124+ 'remove-empty-rulesets' : false
125+ }
126+ ) ;
127+ } ) ;
128+ } ) ;
38129} ) ;
39130
40131describe ( 'options/remove-empty-rulesets AST manipulation' , function ( ) {
0 commit comments