Add muting.get_muted_topics

(imported from commit 5edb1d36ae66dfc42cf534edc452959df8306661)
This commit is contained in:
Steve Howell 2013-09-10 11:01:38 -04:00
parent 8626276dc3
commit 04c6a8198a
2 changed files with 20 additions and 1 deletions

View File

@ -25,6 +25,16 @@ exports.is_topic_muted = function (stream, topic) {
return sub_dict && sub_dict.get(topic);
};
exports.get_muted_topics = function () {
var topics = [];
muted_topics.each(function (sub_dict, stream) {
_.each(sub_dict.keys(), function (topic) {
topics.push([stream, topic]);
});
});
return topics;
};
return exports;
}());
if (typeof module !== 'undefined') {

View File

@ -30,5 +30,14 @@ var muting = require('js/muting.js');
// test unknown stream is harmless too
muting.unmute_topic('unknown', 'java');
assert(!muting.is_topic_muted('unknown', 'java'));
}());
(function test_get_muted_topics() {
assert.deepEqual(muting.get_muted_topics(), []);
muting.mute_topic('office', 'gossip');
muting.mute_topic('devel', 'java');
assert.deepEqual(muting.get_muted_topics().sort(), [
['devel', 'java'],
['office', 'gossip']
]);
}());