Skip to content

Commit 7405266

Browse files
author
s0ph1e
committed
Add tests for comments ignoring
1 parent 9a01592 commit 7405266

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/css-parser-test.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,43 @@ describe('Parse css urls', function(){
6969
urls.should.be.instanceof(Array);
7070
urls.should.have.length(0);
7171
});
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+
});
72111
});

0 commit comments

Comments
 (0)