mirror of https://github.com/zulip/zulip.git
Add narrowed_to_topic() helper function.
(imported from commit 9190caa9b183893fb7ae883686b9bdbd661d5895)
This commit is contained in:
parent
a4e2ed9fd2
commit
e79e74ade4
|
@ -435,6 +435,14 @@ exports.narrowed_by_reply = function () {
|
|||
current_filter.operands("topic").length === 1));
|
||||
};
|
||||
|
||||
exports.narrowed_to_topic = function () {
|
||||
if (current_filter === undefined) {
|
||||
return false;
|
||||
}
|
||||
return (current_filter.has_operator("stream") &&
|
||||
current_filter.has_operator("topic"));
|
||||
};
|
||||
|
||||
exports.narrowed_to_search = function () {
|
||||
return (current_filter !== undefined) && current_filter.is_search();
|
||||
};
|
||||
|
|
|
@ -27,26 +27,31 @@ function set_filter(operators) {
|
|||
assert(!narrow.narrowed_to_pms());
|
||||
assert(!narrow.narrowed_by_reply());
|
||||
assert(!narrow.narrowed_to_search());
|
||||
assert(!narrow.narrowed_to_topic());
|
||||
|
||||
set_filter([['stream', 'Foo']]);
|
||||
assert(!narrow.narrowed_to_pms());
|
||||
assert(!narrow.narrowed_by_reply());
|
||||
assert(!narrow.narrowed_to_search());
|
||||
assert(!narrow.narrowed_to_topic());
|
||||
|
||||
set_filter([['pm-with', 'steve@zulip.com']]);
|
||||
assert(narrow.narrowed_to_pms());
|
||||
assert(narrow.narrowed_by_reply());
|
||||
assert(!narrow.narrowed_to_search());
|
||||
assert(!narrow.narrowed_to_topic());
|
||||
|
||||
set_filter([['stream', 'Foo'], ['topic', 'bar']]);
|
||||
assert(!narrow.narrowed_to_pms());
|
||||
assert(narrow.narrowed_by_reply());
|
||||
assert(!narrow.narrowed_to_search());
|
||||
assert(narrow.narrowed_to_topic());
|
||||
|
||||
set_filter([['search', 'grail']]);
|
||||
assert(!narrow.narrowed_to_pms());
|
||||
assert(!narrow.narrowed_by_reply());
|
||||
assert(narrow.narrowed_to_search());
|
||||
assert(!narrow.narrowed_to_topic());
|
||||
}());
|
||||
|
||||
(function test_operators() {
|
||||
|
|
Loading…
Reference in New Issue