fix fireball/issues/7969 (#3010)

* fix fireball/issues/7969

* add test color
This commit is contained in:
Knox
2018-07-24 16:15:52 +08:00
committed by pandamicro
parent c4593dd23b
commit d6ea17f8f1
3 changed files with 19 additions and 8 deletions
+7 -3
View File
@@ -2,16 +2,20 @@ module('color');
test('basic test', function() {
var testColor = new cc.Color( 255, 255, 0, 127.5 );
equal ( testColor.toHEX('#rrggbbaa'), "ffff007f", "The value must be ffff007f" );
equal ( testColor.toHEX('#rrggbb'), "ffff00", "The value must be ffff00" );
equal ( testColor.toHEX('#rgb'), "ff0", "The value must be ff0" );
equal ( testColor.toCSS('#rrggbbaa'), "#ffff007f", "The value must be ffff007f" );
equal ( testColor.toCSS('#rrggbb'), "#ffff00", "The value must be #ffff00" );
equal ( testColor.toCSS('#rgb'), "#ff0", "The value must be #ff0" );
testColor = new cc.Color( 0.3 * 255, 255, 0, 127.5 );
equal ( testColor.toHEX('#rrggbb'), "4cff00", "The value must be ffff00" );
equal ( testColor.toHEX('#rrggbbaa'), "4cff007f", "The value must be 4cff007f" );
equal ( testColor.toHEX('#rrggbb'), "4cff00", "The value must be 4cff00" );
equal ( testColor.toHEX('#rgb'), "4f0", "The value must be ff0" );
equal ( testColor.toCSS('#rrggbb'), "#4cff00", "The value must be #ffff00" );
equal ( testColor.toCSS('#rgb'), "#4f0", "The value must be #ff0" );
equal ( testColor.toCSS('#rrggbbaa'), "#4cff007f", "The value must be #4cff007f" );
equal ( testColor.toCSS('#rrggbb'), "#4cff00", "The value must be #4cff00" );
equal ( testColor.toCSS('#rgb'), "#4f0", "The value must be #4f0" );
testColor = new cc.Color( 255, 0, 0, 255 );
deepEqual ( testColor.toHSV(), { h: 0, s: 1, v: 1 }, "The value must be { h:0, s:1, v:1 }" );