node tests: Fully cover compare_by_pms() in typeahead_helper.js.

This commit is contained in:
Joshua Pan 2017-06-20 14:35:03 -07:00 committed by showell
parent 1c34a3ae54
commit b48f8447e2
1 changed files with 40 additions and 0 deletions

View File

@ -183,6 +183,46 @@ _.each(matches, function (person) {
'zman@test.net',
'b_bot@example.com',
]);
people.deactivate(person);
// Test sort_recipients with pm counts
matches[0].pm_recipient_count = 50;
matches[1].pm_recipient_count = 2;
matches[2].pm_recipient_count = 32;
matches[3].pm_recipient_count = 42;
matches[4].pm_recipient_count = 0;
matches[5].pm_recipient_count = 1;
assert.deepEqual(get_typeahead_result("b", "Linux"), [
'b_user_2@zulip.net',
'b_user_1@zulip.net',
'b_bot@example.com',
'a_bot@zulip.com',
'a_user@zulip.org',
'zman@test.net',
]);
// Test sort_recipients with duplicate people
matches.push(matches[0]);
var recipients = th.sort_recipients(matches, "b", "Linux");
var recipients_email = _.map(recipients, function (person) {
return person.email;
});
var expected = [
'b_user_2@zulip.net',
'b_user_1@zulip.net',
'b_bot@example.com',
'a_bot@zulip.com',
'a_bot@zulip.com',
'a_user@zulip.org',
'zman@test.net',
];
assert.deepEqual(recipients_email, expected);
// Reset matches
matches.splice(matches.length-1, 1);
}());
(function test_highlight_with_escaping() {