Created
August 16, 2012 02:14
-
-
Save toolness/3365671 to your computer and use it in GitHub Desktop.
CSS testing script for refactorings
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
(function(jQuery) { | |
var $ = jQuery; | |
function test(name, selectors, css) { | |
console.log("CSS test: " + name); | |
selectors.forEach(function(selector) { | |
var passed = 0; | |
var elements = $(selector); | |
if (!elements.length) | |
return console.error(" FAIL - nothing matches " + selector); | |
elements.each(function() { | |
var $el = $(this); | |
for (var property in css) { | |
var value = $el.css(property); | |
if (!value.match(css[property])) | |
return console.error(" FAIL - " + selector + " " + property + | |
" is " + value + ", not " + css[property]); | |
} | |
passed++; | |
}); | |
if (elements.length == passed) | |
console.log(" OK - " + selector + " (" + passed + ")"); | |
}); | |
} | |
test("font is Ubuntu Mono", [ | |
".CodeMirror", ".CodeMirror-lines", ".CodeMirror textarea", | |
".CodeMirror-gutter-text", ".cm-s-jsbin span.cm-comment" | |
], { | |
'font-family': /Ubuntu Mono/ | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example output: