@@ -69,4 +69,43 @@ describe('Parse css urls', function(){
69
69
urls . should . be . instanceof ( Array ) ;
70
70
urls . should . have . length ( 0 ) ;
71
71
} ) ;
72
+
73
+ describe ( 'comments' , function ( ) {
74
+ it ( 'should ignore comments and return empty array if there are only comments in text' , function ( ) {
75
+ var text = '\
76
+ /* @import url("a.css"); \
77
+ @import url("b.css"); \
78
+ .image { background-image: url("bg.png"); } */ \
79
+ \
80
+ ' ;
81
+
82
+ var urls = parseCssUrls ( text ) ;
83
+ urls . should . be . instanceof ( Array ) ;
84
+ urls . should . have . length ( 0 ) ;
85
+ } ) ;
86
+
87
+ it ( 'should ignore comments and return only urls from rules' , function ( ) {
88
+ var text = '\
89
+ /* @import url("a.css"); */ \
90
+ @import url("b.css"); \
91
+ ' ;
92
+
93
+ var urls = parseCssUrls ( text ) ;
94
+ urls . should . be . instanceof ( Array ) ;
95
+ urls . should . have . length ( 1 ) ;
96
+ urls . should . containEql ( 'b.css' ) ;
97
+ } ) ;
98
+
99
+ it ( 'should ignore comments because they may be tricky' , function ( ) {
100
+ var text = '\
101
+ /* @import hahahaha */\
102
+ @import url("a.css"); \
103
+ ' ;
104
+
105
+ var urls = parseCssUrls ( text ) ;
106
+ urls . should . be . instanceof ( Array ) ;
107
+ urls . should . have . length ( 1 ) ;
108
+ urls . should . containEql ( 'a.css' ) ;
109
+ } ) ;
110
+ } ) ;
72
111
} ) ;
0 commit comments