aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/color.js2
-rw-r--r--tests/test-color.js31
2 files changed, 32 insertions, 1 deletions
diff --git a/lib/color.js b/lib/color.js
index 75f2c9a..2da2fa7 100644
--- a/lib/color.js
+++ b/lib/color.js
@@ -6,7 +6,7 @@
// originally from
// http://www.mjijackson.com/2008/02\
// /rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
-exports.Color = function Color(r, g, b) {
+var Color = exports.Color = function Color(r, g, b) {
this.Luminosity = 0.85;
this.Desaturated = 0.4;
diff --git a/tests/test-color.js b/tests/test-color.js
new file mode 100644
index 0000000..7394057
--- /dev/null
+++ b/tests/test-color.js
@@ -0,0 +1,31 @@
+/*global exports: false, require: false */
+// TODO: add some failing tests as well
+"use strict";
+var util = require("color");
+
+// testing Color object
+exports.ensureColorNew = function (test) {
+ var col = new util.Color(255, 255, 166);
+ test.assertEqual(col.toString(), "#ffffa6",
+ "creation of new RGB Color object");
+};
+
+exports.ensureColorUpdate = function (test) {
+ var col = new util.Color(255, 255, 166);
+ col.update(255, 224, 176);
+ test.assertEqual(col.toString(), "#ffe0b0",
+ "updating Color object");
+};
+
+exports.ensureColorHSL = function (test) {
+ var col = new util.Color(255, 224, 176);
+ test.assertEqual(col.hsl().toSource(),
+ "[0.10126582278481013, 1, 0.8450980392156863]",
+ "converting to HSL model");
+};
+
+exports.ensureColorLight = function (test) {
+ var col = new util.Color(255, 224, 176);
+ test.assertEqual(col.lightColor().toString(), "#e8dcc9",
+ "getting a light color");
+};