mirror of https://github.com/zulip/zulip.git
Add a test for stream_color.js (pick_color).
(imported from commit a49f96a4a7b61ef51c057e8a3f11c116d77ebb49)
This commit is contained in:
parent
cef72fd8b8
commit
cf1d94edef
|
@ -180,3 +180,6 @@ exports.get_color_class = _.memoize(function (color) {
|
||||||
return exports;
|
return exports;
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
if (typeof module !== 'undefined') {
|
||||||
|
module.exports = stream_color;
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ export NODE_PATH=$STATIC_DIR
|
||||||
NODEJS=$(which nodejs || which node)
|
NODEJS=$(which nodejs || which node)
|
||||||
|
|
||||||
$NODEJS filter.js
|
$NODEJS filter.js
|
||||||
|
$NODEJS stream_color.js
|
||||||
$NODEJS util.js
|
$NODEJS util.js
|
||||||
$NODEJS message_list.js
|
$NODEJS message_list.js
|
||||||
$NODEJS message_tour.js
|
$NODEJS message_tour.js
|
||||||
|
|
|
@ -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);
|
||||||
|
}());
|
Loading…
Reference in New Issue