refactor: Use people.my_current_email() in filter.js.

This commit is contained in:
Steve Howell
2017-01-20 09:41:07 -08:00
committed by Tim Abbott
parent e10c6719d9
commit 2c684bf39f
2 changed files with 16 additions and 5 deletions

View File

@@ -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');

View File

@@ -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':