mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 19:06:09 +00:00
Add filter.is_stream_topic_only().
This commit is contained in:
@@ -669,6 +669,31 @@ function make_sub(name, stream_id) {
|
|||||||
assert.equal(Filter.describe(narrow), string);
|
assert.equal(Filter.describe(narrow), string);
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
(function test_is_functions() {
|
||||||
|
var terms = [
|
||||||
|
{operator: 'stream', operand: 'My Stream'},
|
||||||
|
];
|
||||||
|
var filter = new Filter(terms);
|
||||||
|
assert.equal(filter.is_stream_only(), true);
|
||||||
|
assert.equal(filter.is_stream_topic_only(), false);
|
||||||
|
|
||||||
|
terms = [
|
||||||
|
{operator: 'stream', operand: 'My Stream'},
|
||||||
|
{operator: 'topic', operand: 'My Topic'},
|
||||||
|
];
|
||||||
|
filter = new Filter(terms);
|
||||||
|
assert.equal(filter.is_stream_only(), false);
|
||||||
|
assert.equal(filter.is_stream_topic_only(), true);
|
||||||
|
|
||||||
|
terms = [
|
||||||
|
{operator: 'stream', operand: 'My Stream', negated: true},
|
||||||
|
{operator: 'topic', operand: 'My Topic'},
|
||||||
|
];
|
||||||
|
filter = new Filter(terms);
|
||||||
|
assert.equal(filter.is_stream_only(), false);
|
||||||
|
assert.equal(filter.is_stream_topic_only(), false);
|
||||||
|
}());
|
||||||
|
|
||||||
(function test_update_email() {
|
(function test_update_email() {
|
||||||
var terms = [
|
var terms = [
|
||||||
{operator: 'pm-with', operand: 'steve@foo.com'},
|
{operator: 'pm-with', operand: 'steve@foo.com'},
|
||||||
|
|||||||
@@ -411,6 +411,14 @@ Filter.prototype = {
|
|||||||
return (term.operator === 'stream');
|
return (term.operator === 'stream');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
is_stream_topic_only: function () {
|
||||||
|
if (this._operators.length !== 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.has_operator('stream') && this.has_operator('topic');
|
||||||
|
},
|
||||||
|
|
||||||
update_email: function (user_id, new_email) {
|
update_email: function (user_id, new_email) {
|
||||||
_.each(this._operators, function (term) {
|
_.each(this._operators, function (term) {
|
||||||
switch (term.operator) {
|
switch (term.operator) {
|
||||||
|
|||||||
Reference in New Issue
Block a user