forked from zulip/zulip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We will use this to find the first id from a list of message ids that matches a filter. (This will help us during narrowing to determine whether we have at least one good message locally, so that we can render something useful before waiting for the server.)
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ zrequire('people'); | |
zrequire('Handlebars', 'handlebars'); | ||
zrequire('Filter', 'js/filter'); | ||
|
||
set_global('message_store', {}); | ||
set_global('page_params', {}); | ||
set_global('feature_flags', {}); | ||
|
||
|
@@ -800,6 +801,32 @@ function make_sub(name, stream_id) { | |
assert.deepEqual(term_types, ['stream', 'topic', 'sender']); | ||
}()); | ||
|
||
(function test_first_valid_id_from() { | ||
const terms = [ | ||
{operator: 'is', operand: 'alerted'}, | ||
]; | ||
|
||
const filter = new Filter(terms); | ||
|
||
const messages = { | ||
5: { id: 5, alerted: true }, | ||
10: { id: 10 }, | ||
20: { id: 20, alerted: true }, | ||
30: { id: 30, type: 'stream' }, | ||
40: { id: 40, alerted: false }, | ||
}; | ||
|
||
const msg_ids = [10, 20, 30, 40]; | ||
|
||
message_store.get = () => {}; | ||
|
||
assert.equal(filter.first_valid_id_from(msg_ids), undefined); | ||
|
||
message_store.get = (msg_id) => messages[msg_id]; | ||
|
||
assert.equal(filter.first_valid_id_from(msg_ids), 20); | ||
}()); | ||
|
||
(function test_update_email() { | ||
var terms = [ | ||
{operator: 'pm-with', operand: '[email protected]'}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters