Created
July 1, 2013 12:40
-
-
Save ignovak/5900429 to your computer and use it in GitHub Desktop.
Tests for https://github.com/enb-make/enb/blob/master/lib/preprocess/css-preprocessor.js#L51-L69
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var css = [ | |
["background: url('pic.png');", "background: url('../../common.blocks/pic/pic.png');"], | |
["background: #fff url('pic.png');", "background: #fff url('../../common.blocks/pic/pic.png');"], | |
["background: url('pic.png') #fff;", "background: url('../../common.blocks/pic/pic.png') #fff;"], | |
["background: url('http://ya.ru/pic.png');", "background: url('http://ya.ru/pic.png');"], | |
["background: url('//ya.ru/pic.png');", "background: url('//ya.ru/pic.png');"], | |
["background-image: url('pic.png');", "background-image: url('../../common.blocks/pic/pic.png');"], | |
["background: url('pic.png');background: url('pic.png');", "background: url('../../common.blocks/pic/pic.png');background: url('../../common.blocks/pic/pic.png');"], | |
["background: url(pic.png);", "background: url(../../common.blocks/pic/pic.png);"], | |
["background: #fff url(pic.png);", "background: #fff url(../../common.blocks/pic/pic.png);"], | |
["background: url(pic.png) #fff;", "background: url(../../common.blocks/pic/pic.png) #fff;"], | |
["background: url(http://ya.ru/pic.png);", "background: url(http://ya.ru/pic.png);"], | |
["background: url(//ya.ru/pic.png);", "background: url(//ya.ru/pic.png);"], | |
["background-image: url(pic.png);", "background-image: url(../../common.blocks/pic/pic.png);"], | |
["background: url(pic.png);background: url(pic.png);", "background: url(../../common.blocks/pic/pic.png);background: url(../../common.blocks/pic/pic.png);"], | |
["background-image: url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20rl(%23l)20fill%3D%22none%22%2F%3E%3C%2Fsvg%3E');", "background-image: url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20rl(%23l)20fill%3D%22none%22%2F%3E%3C%2Fsvg%3E');"], | |
], | |
count = 0, | |
CssPreprocessor = require('./lib/preprocess/css-preprocessor'), | |
preprocessCss = new CssPreprocessor(); | |
preprocessCss.setCssRelativeUrlBuilder(function(path) { | |
return '../../common.blocks/pic/' + path; | |
}); | |
css.forEach(function(item) { | |
check(item[1], preprocessCss._processUrls(item[0], '../../common.blocks/pic/')); | |
count++; | |
}); | |
console.log('\033[32m%s tests passed\033[0m', count); | |
function check(expected, result) { | |
console.assert(expected == result, '\nexpected: \033[31m' + expected, '\n\nresult: ' + result + '\033[0m') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment