Skip to content

Commit

Permalink
Convert RGB color to HEX in assertion (closes madrobby#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
kossnocorp committed Jul 1, 2011
1 parent 1daf83c commit b928798
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion test/fx.html
Expand Up @@ -22,6 +22,20 @@ <h1>Zepto FX unit tests</h1>
<div id="anim_zero_duration_callback_test"></div>

<script>
function colorToHex (color) {
if (color.substr(0, 1) === '#') {
return color;
}

var digits = /(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec( color.toLowerCase() ),
red = parseInt(digits[2]),
green = parseInt(digits[3]),
blue = parseInt(digits[4]),
rgb = blue | (green << 8) | (red << 16);

return digits[1] + '#' + rgb.toString(16);
};

Evidence.TestCase.extend('ZeptoFXTest', {

testAnim: function(t){
Expand All @@ -35,7 +49,7 @@ <h1>Zepto FX unit tests</h1>
t.assertEqual('translate3d(100px, 100px, 100px) rotateZ(90deg)', el.style.webkitTransform);
t.assertEqual('ease-out', el.style.webkitTransitionTimingFunction);
t.assertEqual('0.5', el.style.opacity);
t.assertEqual('#BADA55', el.style.backgroundColor.toUpperCase());
t.assertEqual( '#BADA55', colorToHex(el.style.backgroundColor).toUpperCase() );
},

testDuration: function(t){
Expand Down

0 comments on commit b928798

Please sign in to comment.