mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
Change operator canonicalizations.
Streams are converted to their "official" names now. Topics are not canonicalized at all. All other operands continue to be lowercased. Since we don't lowercase stream/topic at the parsing stage, we have to modify the predicate function to do the lowercasing of stream/topic to enable case-insensitive comparisons. This is slightly more expensive. The server-side predicate functions are already case-insensitive. (imported from commit 286f118c6c3ff9d23b37c7f958cab4c0eacd5feb)
This commit is contained in:
@@ -42,7 +42,7 @@ var Filter = global.Filter;
|
||||
assert.equal(Filter.canonicalize_operator('Stream'), 'stream');
|
||||
assert.equal(Filter.canonicalize_operator('Subject'), 'topic');
|
||||
|
||||
assert.deepEqual(Filter.canonicalize_tuple(['Stream', 'Denmark']), ['stream', 'denmark']);
|
||||
assert.deepEqual(Filter.canonicalize_tuple(['Stream', 'Denmark']), ['stream', 'Denmark']);
|
||||
}());
|
||||
|
||||
(function test_predicates() {
|
||||
|
||||
@@ -27,12 +27,12 @@ var stream_data = global.stream_data;
|
||||
var operators = [['stream', 'Foo'], ['topic', 'Bar'], ['search', 'yo']];
|
||||
narrow._set_current_filter(new Filter(operators));
|
||||
|
||||
assert.equal(narrow.stream(), 'foo');
|
||||
assert.equal(narrow.stream(), 'Foo');
|
||||
}());
|
||||
|
||||
(function test_operators() {
|
||||
var operators = [['stream', 'Foo'], ['topic', 'Bar'], ['search', 'yo']];
|
||||
var canonical_operators = [['stream', 'foo'], ['topic', 'bar'], ['search', 'yo']];
|
||||
var operators = [['stream', 'Foo'], ['topic', 'Bar'], ['search', 'Yo']];
|
||||
var canonical_operators = [['stream', 'Foo'], ['topic', 'Bar'], ['search', 'yo']];
|
||||
narrow._set_current_filter(new Filter(operators));
|
||||
|
||||
assert.deepEqual(narrow.operators(), canonical_operators);
|
||||
@@ -44,8 +44,8 @@ var stream_data = global.stream_data;
|
||||
|
||||
var opts = {};
|
||||
narrow.set_compose_defaults(opts);
|
||||
assert.equal(opts.stream, 'foo');
|
||||
assert.equal(opts.subject, 'bar');
|
||||
assert.equal(opts.stream, 'Foo');
|
||||
assert.equal(opts.subject, 'Bar');
|
||||
|
||||
stream_data.add_sub('ROME', {name: 'ROME'});
|
||||
operators = [['stream', 'rome']];
|
||||
|
||||
Reference in New Issue
Block a user