Add a test for stream_color.js (pick_color).

(imported from commit a49f96a4a7b61ef51c057e8a3f11c116d77ebb49)
This commit is contained in:
Steve Howell 2013-08-08 19:27:49 -04:00
parent cef72fd8b8
commit cf1d94edef
3 changed files with 25 additions and 0 deletions

View File

@ -180,3 +180,6 @@ exports.get_color_class = _.memoize(function (color) {
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = stream_color;
}

View File

@ -9,6 +9,7 @@ export NODE_PATH=$STATIC_DIR
NODEJS=$(which nodejs || which node)
$NODEJS filter.js
$NODEJS stream_color.js
$NODEJS util.js
$NODEJS message_list.js
$NODEJS message_tour.js

View File

@ -0,0 +1,21 @@
var assert = require('assert');
(function set_up_dependencies () {
global._ = require('third/underscore/underscore.js');
global.$ = function (f) {};
global.stream_color = require('js/stream_color.js');
}());
var stream_color = global.stream_color;
(function test_pick_color () {
var used_colors = ["#76ce90", "#fae589"];
// Colors are assigned randomly, so this test is a little vague and brittle,
// but we can verify a few things, like not reusing colors and making sure
// the color has length 7.
var color = stream_color.pick_color(used_colors);
assert.notEqual(color, "#76ce90");
assert.notEqual(color, "#fae589");
assert.equal(color.length, 7);
}());