Skip to content

Commit 34a4370

Browse files
committed
Add test for utils/css.js isEmbedded function
1 parent 8e9edee commit 34a4370

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/utils/css.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ function getSourcesPaths(text) {
2929
.value();
3030
}
3131

32+
module.exports.isEmbedded = isEmbedded;
3233
module.exports.getSourcesPaths = getSourcesPaths;

test/utils-css-test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var css = require('../lib/utils/css');
2+
3+
var should = require('should')
4+
describe('Css utils', function(){
5+
describe('#isEmbedded(src)', function(){
6+
it('should return true if src is base64-encoded', function(){
7+
var base64_1 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAA \
8+
ABlBMVEUAAAD///+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeN \
9+
Ge4Ug9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC';
10+
var base64_2 = 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D';
11+
css.isEmbedded(base64_1).should.be.true;
12+
css.isEmbedded(base64_2).should.be.true;
13+
});
14+
it('should return false if src is not base64-encoded', function(){
15+
var path = 'images/px/arrow-090-small.png';
16+
var url = 'https://www.google.com.ua/images/srpr/logo11w.png';
17+
css.isEmbedded(path).should.be.false;
18+
css.isEmbedded(url).should.be.false;
19+
});
20+
});
21+
22+
23+
});

0 commit comments

Comments
 (0)