Handle undefined keys in muting.is_topic_muted

(imported from commit 96a9f0253e1c0e72a2b05577118dac438d190994)
This commit is contained in:
Steve Howell 2013-09-10 16:42:48 -04:00
parent f616148181
commit c6131b630b
2 changed files with 11 additions and 0 deletions

View File

@ -21,6 +21,9 @@ exports.unmute_topic = function (stream, topic) {
};
exports.is_topic_muted = function (stream, topic) {
if (stream === undefined) {
return false;
}
var sub_dict = muted_topics.get(stream);
return sub_dict && sub_dict.get(topic);
};

View File

@ -11,6 +11,14 @@ set_global('page_params', {
var muting = require('js/muting.js');
(function test_edge_cases() {
// private messages
assert(!muting.is_topic_muted(undefined, undefined));
// defensive
assert(!muting.is_topic_muted('nonexistent', undefined));
}());
(function test_basics() {
assert(!muting.is_topic_muted('devel', 'java'));
muting.mute_topic('devel', 'java');