mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
refactor: Use people.my_current_email() in filter.js.
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
global.stub_out_jquery();
|
||||
|
||||
add_dependencies({
|
||||
util: 'js/util.js',
|
||||
people: 'js/people.js',
|
||||
stream_data: 'js/stream_data.js',
|
||||
util: 'js/util.js',
|
||||
});
|
||||
|
||||
set_global('page_params', {
|
||||
email: 'hamlet@zulip.com',
|
||||
domain: 'zulip.com',
|
||||
});
|
||||
|
||||
@@ -13,6 +15,15 @@ set_global('feature_flags', {});
|
||||
var Filter = require('js/filter.js');
|
||||
var _ = global._;
|
||||
|
||||
var me = {
|
||||
email: 'me@example.com',
|
||||
user_id: 30,
|
||||
full_name: 'Me Myself',
|
||||
};
|
||||
|
||||
people.add(me);
|
||||
people.initialize_current_user(me.email);
|
||||
|
||||
function assert_same_operators(result, terms) {
|
||||
terms = _.map(terms, function (term) {
|
||||
// If negated flag is undefined, we explicitly
|
||||
@@ -147,11 +158,11 @@ function assert_same_operators(result, terms) {
|
||||
|
||||
term = Filter.canonicalize_term({operator: 'sender', operand: 'me'});
|
||||
assert.equal(term.operator, 'sender');
|
||||
assert.equal(term.operand, 'hamlet@zulip.com');
|
||||
assert.equal(term.operand, 'me@example.com');
|
||||
|
||||
term = Filter.canonicalize_term({operator: 'pm-with', operand: 'me'});
|
||||
assert.equal(term.operator, 'pm-with');
|
||||
assert.equal(term.operand, 'hamlet@zulip.com');
|
||||
assert.equal(term.operand, 'me@example.com');
|
||||
|
||||
term = Filter.canonicalize_term({operator: 'search', operand: 'foo'});
|
||||
assert.equal(term.operator, 'search');
|
||||
|
||||
@@ -156,7 +156,7 @@ Filter.canonicalize_term = function (opts) {
|
||||
case 'pm-with':
|
||||
operand = operand.toString().toLowerCase();
|
||||
if (operand === 'me') {
|
||||
operand = page_params.email;
|
||||
operand = people.my_current_email();
|
||||
}
|
||||
break;
|
||||
case 'search':
|
||||
|
||||
Reference in New Issue
Block a user