mirror of
https://github.com/zulip/zulip.git
synced 2025-11-20 06:28:23 +00:00
Add a test for stream_color.js (pick_color).
(imported from commit a49f96a4a7b61ef51c057e8a3f11c116d77ebb49)
This commit is contained in:
@@ -180,3 +180,6 @@ exports.get_color_class = _.memoize(function (color) {
|
||||
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 filter.js
|
||||
$NODEJS stream_color.js
|
||||
$NODEJS util.js
|
||||
$NODEJS message_list.js
|
||||
$NODEJS message_tour.js
|
||||
|
||||
21
zerver/tests/frontend/node/stream_color.js
Normal file
21
zerver/tests/frontend/node/stream_color.js
Normal 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);
|
||||
}());
|
||||
Reference in New Issue
Block a user