Skip to content
Browse files

Convert RGB color to HEX in assertion (closes #203)

  • Loading branch information...
1 parent 1daf83c commit b928798ac695bf27d93b0116438c9a9593355c4e @kossnocorp kossnocorp committed Jun 17, 2011
Showing with 15 additions and 1 deletion.
  1. +15 −1 test/fx.html
View
16 test/fx.html
@@ -22,6 +22,20 @@
<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){
@@ -35,7 +49,7 @@
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){

0 comments on commit b928798

Please sign in to comment.
Something went wrong with that request. Please try again.