mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
Set negated flag explicity to false in JS code.
For negated search terms, we weren't explicitly setting "negated" to false when callers left it undefined, which was mostly fine, since undefined is falsey, but it is better to define it explicitly for debugging/testing purposes. (imported from commit 68a2790b510d17caed8ca11c38188545d1dcc347)
This commit is contained in:
@@ -135,6 +135,12 @@ Filter.canonicalize_term = function (opts) {
|
||||
var operator = opts.operator;
|
||||
var operand = opts.operand;
|
||||
|
||||
// Make negated be explictly false for both clarity and
|
||||
// simplifying deepEqual checks in the tests.
|
||||
if (!negated) {
|
||||
negated = false;
|
||||
}
|
||||
|
||||
if (operator === undefined) {
|
||||
blueslip.error("Old-style tuple operators are still in use for canonicalize_term");
|
||||
operator = opts[0];
|
||||
@@ -237,7 +243,7 @@ Filter.parse = function (str) {
|
||||
if (search_term.length > 0) {
|
||||
operator = 'search';
|
||||
operand = search_term.join(' ');
|
||||
term = {operator: operator, operand: operand};
|
||||
term = {operator: operator, operand: operand, negated: false};
|
||||
operators.push(term);
|
||||
}
|
||||
return operators;
|
||||
|
||||
@@ -14,8 +14,15 @@ var Filter = require('js/filter.js');
|
||||
var _ = global._;
|
||||
|
||||
function assert_same_operators(result, terms) {
|
||||
result = _.map(result, function (term) {
|
||||
terms = _.map(result, function (term) {
|
||||
// If negated flag is undefined, we explicitly
|
||||
// set it to false.
|
||||
var negated = term.negated;
|
||||
if (!negated) {
|
||||
negated = false;
|
||||
}
|
||||
return {
|
||||
negated: negated,
|
||||
operator: term.operator,
|
||||
operand: term.operand
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user