Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

bootstrap_typeahead: Change item_html to accept query and return a func.

Pratik Chanda6045243c8c30
diff --git a/web/src/bootstrap_typeahead.ts b/web/src/bootstrap_typeahead.ts
index 28116576c93..7492c483197 100644
--- a/web/src/bootstrap_typeahead.ts
+++ b/web/src/bootstrap_typeahead.ts
@@ -222,7 +222,7 @@ export class Typeahead<ItemType extends string | object> {
items: number;
matcher: (item: ItemType, query: string) => boolean;
sorter: (items: ItemType[], query: string) => ItemType[];
- item_html: (item: ItemType, query: string) => string | undefined;
+ item_html: (query: string) => (item: ItemType) => string | undefined;
updater: (
item: ItemType,
query: string,
@@ -590,10 +590,11 @@ export class Typeahead<ItemType extends string | object> {
}
render(final_items: ItemType[], matching_items: ItemType[]): this {
+ const render_item = this.item_html(this.query);
const $items: JQuery[] = final_items.map((item) => {
const $i = $(ITEM_HTML);
this.values.set(the($i), item);
- const item_html = this.item_html(item, this.query) ?? "";
+ const item_html = render_item(item) ?? "";
const $item_html = $i.find("a").html(item_html);
const option_label_html = this.option_label(matching_items, item);
@@ -952,7 +953,7 @@ export class Typeahead<ItemType extends string | object> {
* =========================== */
type TypeaheadOptions<ItemType> = {
- item_html: (item: ItemType, query: string) => string | undefined;
+ item_html: (query: string) => (item: ItemType) => string | undefined;
items?: number;
source: (query: string, input_element: TypeaheadInputElement) => ItemType[];
// optional options
diff --git a/web/src/composebox_typeahead.ts b/web/src/composebox_typeahead.ts
index 240f97c7cd6..baed003d931 100644
--- a/web/src/composebox_typeahead.ts
+++ b/web/src/composebox_typeahead.ts
@@ -1262,41 +1262,45 @@ export function get_candidates(
return [];
}
-export function content_item_html(item: TypeaheadSuggestion): string | undefined {
- switch (item.type) {
- case "emoji":
- return typeahead_helper.render_emoji(item);
- case "user_group":
- case "user":
- case "broadcast":
- return typeahead_helper.render_person_or_user_group(item, token);
- case "slash":
- return typeahead_helper.render_typeahead_item({
- primary: item.text,
- secondary: item.info,
- });
- case "stream":
- return typeahead_helper.render_stream(item);
- case "syntax":
- return typeahead_helper.render_typeahead_item({
- primary: item.language,
- is_default_language:
- item.language !== "" &&
- item.language === realm.realm_default_code_block_language,
- });
- case "topic_jump":
- return typeahead_helper.render_typeahead_item({primary: item.message});
- case "topic_list": {
- if (item.is_channel_link) {
- return typeahead_helper.render_stream(item.stream_data);
+export function content_item_html(
+ _query: string,
+): (item: TypeaheadSuggestion) => string | undefined {
+ return function (item: TypeaheadSuggestion): string | undefined {
+ switch (item.type) {
+ case "emoji":
+ return typeahead_helper.render_emoji(item);
+ case "user_group":
+ case "user":
+ case "broadcast":
+ return typeahead_helper.render_person_or_user_group(item, token);
+ case "slash":
+ return typeahead_helper.render_typeahead_item({
+ primary: item.text,
+ secondary: item.info,
+ });
+ case "stream":
+ return typeahead_helper.render_stream(item);
+ case "syntax":
+ return typeahead_helper.render_typeahead_item({
+ primary: item.language,
+ is_default_language:
+ item.language !== "" &&
+ item.language === realm.realm_default_code_block_language,
+ });
+ case "topic_jump":
+ return typeahead_helper.render_typeahead_item({primary: item.message});
+ case "topic_list": {
+ if (item.is_channel_link) {
+ return typeahead_helper.render_stream(item.stream_data);
+ }
+ return typeahead_helper.render_stream_topic(item);
}
- return typeahead_helper.render_stream_topic(item);
+ case "time_jump":
+ return typeahead_helper.render_typeahead_item({primary: item.message});
+ default:
+ return undefined;
}
- case "time_jump":
- return typeahead_helper.render_typeahead_item({primary: item.message});
- default:
- return undefined;
- }
+ };
}
export function content_typeahead_selected(
@@ -1559,13 +1563,15 @@ export function initialize_topic_edit_typeahead(
};
return new Typeahead(bootstrap_typeahead_input, {
dropup,
- item_html(item: string): string {
- const is_empty_string_topic = item === "";
- const topic_display_name = util.get_final_topic_display_name(item);
- return typeahead_helper.render_typeahead_item({
- primary: topic_display_name,
- is_empty_string_topic,
- });
+ item_html(_query: string): (item: string) => string {
+ return function (item: string): string {
+ const is_empty_string_topic = item === "";
+ const topic_display_name = util.get_final_topic_display_name(item);
+ return typeahead_helper.render_typeahead_item({
+ primary: topic_display_name,
+ is_empty_string_topic,
+ });
+ };
},
matcher(item: string, query: string): boolean {
const matcher = get_topic_matcher(query);
@@ -1745,16 +1751,18 @@ export function initialize({
return [...people_candidates, ...topics];
},
items: max_num_items,
- item_html(item: string | UserPillData): string {
- if (typeof item === "string") {
- const is_empty_string_topic = item === "";
- const topic_display_name = util.get_final_topic_display_name(item);
- return typeahead_helper.render_typeahead_item({
- primary: topic_display_name,
- is_empty_string_topic,
- });
- }
- return typeahead_helper.render_person_or_user_group(item);
+ item_html(_query: string): (item: string | UserPillData) => string {
+ return function (item: string | UserPillData): string {
+ if (typeof item === "string") {
+ const is_empty_string_topic = item === "";
+ const topic_display_name = util.get_final_topic_display_name(item);
+ return typeahead_helper.render_typeahead_item({
+ primary: topic_display_name,
+ is_empty_string_topic,
+ });
+ }
+ return typeahead_helper.render_person_or_user_group(item);
+ };
},
matcher(item: UserPillData | string, query: string): boolean {
if (typeof item === "string") {
@@ -1843,8 +1851,9 @@ export function initialize({
source: get_pm_people,
items: max_num_items,
dropup: true,
- item_html(item: UserGroupPillData | UserPillData) {
- return typeahead_helper.render_person_or_user_group(item);
+ item_html(_query: string): (item: UserGroupPillData | UserPillData) => string {
+ return (item: UserGroupPillData | UserPillData) =>
+ typeahead_helper.render_person_or_user_group(item);
},
matcher(): boolean {
return true;
diff --git a/web/src/custom_profile_fields_ui.ts b/web/src/custom_profile_fields_ui.ts
index db78627f9fc..7be58376b2e 100644
--- a/web/src/custom_profile_fields_ui.ts
+++ b/web/src/custom_profile_fields_ui.ts
@@ -417,8 +417,9 @@ export function initialize_custom_pronouns_type_fields(element_id: string): void
sorter(items, query) {
return bootstrap_typeahead.defaultSorter(items, query);
},
- item_html(item) {
- return typeahead_helper.render_typeahead_item({primary: item});
+ item_html(_query: string) {
+ return (item: string) =>
+ typeahead_helper.render_typeahead_item({primary: item});
},
});
});
diff --git a/web/src/pill_typeahead.ts b/web/src/pill_typeahead.ts
index 8f09726b90a..6f6c3adffe4 100644
--- a/web/src/pill_typeahead.ts
+++ b/web/src/pill_typeahead.ts
@@ -47,8 +47,8 @@ export function set_up_user(
source(_query: string): UserPillData[] {
return user_pill.typeahead_source(pills, exclude_bots);
},
- item_html(item: UserPillData, _query: string): string {
- return typeahead_helper.render_person(item);
+ item_html(_query: string): (item: UserPillData) => string {
+ return (item: UserPillData) => typeahead_helper.render_person(item);
},
matcher(item: UserPillData, query: string): boolean {
query = query.toLowerCase();
@@ -96,8 +96,8 @@ export function set_up_stream(
source(_query: string): StreamPillData[] {
return stream_pill.typeahead_source(pills, opts.invite_streams);
},
- item_html(item: StreamPillData, _query: string): string {
- return typeahead_helper.render_stream(item);
+ item_html(_query: string): (item: StreamPillData) => string {
+ return (item: StreamPillData) => typeahead_helper.render_stream(item);
},
matcher(item: StreamPillData, query: string): boolean {
query = query.toLowerCase();
@@ -147,8 +147,8 @@ export function set_up_user_group(
.user_group_source()
.map((user_group) => ({type: "user_group", ...user_group}));
},
- item_html(item: UserGroupPillData, _query: string): string {
- return typeahead_helper.render_user_group(item);
+ item_html(_query: string): (item: UserGroupPillData) => string {
+ return (item: UserGroupPillData) => typeahead_helper.render_user_group(item);
},
matcher(item: UserGroupPillData, query: string): boolean {
query = query.toLowerCase();
@@ -194,13 +194,15 @@ export function set_up_group_setting_typeahead(
return source;
},
- item_html(item: GroupSettingTypeaheadItem, _query: string): string {
- if (item.type === "user_group") {
- return typeahead_helper.render_user_group(item);
- }
+ item_html(_query: string): (item: GroupSettingTypeaheadItem) => string {
+ return (item: GroupSettingTypeaheadItem): string => {
+ if (item.type === "user_group") {
+ return typeahead_helper.render_user_group(item);
+ }
- assert(item.type === "user");
- return typeahead_helper.render_person(item);
+ assert(item.type === "user");
+ return typeahead_helper.render_person(item);
+ };
},
matcher(item: GroupSettingTypeaheadItem, query: string): boolean {
query = query.toLowerCase();
@@ -330,21 +332,23 @@ export function set_up_combined(
}
return source;
},
- item_html(item: TypeaheadItem, query: string): string {
- if (include_streams(query) && item.type === "stream") {
- return typeahead_helper.render_stream(item);
- }
+ item_html(query: string): (item: TypeaheadItem) => string {
+ return (item: TypeaheadItem): string => {
+ if (include_streams(query) && item.type === "stream") {
+ return typeahead_helper.render_stream(item);
+ }
- if (include_user_groups && item.type === "user_group") {
- return typeahead_helper.render_user_group(item);
- }
+ if (include_user_groups && item.type === "user_group") {
+ return typeahead_helper.render_user_group(item);
+ }
- // After reaching this point, it is sure
- // that given item is a person. So this
- // handles `include_users` cases along with
- // default cases.
- assert(item.type === "user");
- return typeahead_helper.render_person(item);
+ // After reaching this point, it is sure
+ // that given item is a person. So this
+ // handles `include_users` cases along with
+ // default cases.
+ assert(item.type === "user");
+ return typeahead_helper.render_person(item);
+ };
},
matcher(item: TypeaheadItem, query: string): boolean {
query = query.toLowerCase();
diff --git a/web/src/search.ts b/web/src/search.ts
index 949fead7f0f..b28bd81054f 100644
--- a/web/src/search.ts
+++ b/web/src/search.ts
@@ -215,8 +215,8 @@ export function initialize(opts: {on_narrow_search: OnNarrowSearch}): void {
helpOnEmptyStrings: true,
stopAdvance: true,
requireHighlight: false,
- item_html(item: string, query: string): string {
- return search_pill.generate_pills_html(item, query);
+ item_html(query: string): (item: string) => string {
+ return (item: string) => search_pill.generate_pills_html(item, query);
},
// When the user starts typing new search operands,
// we want to highlight the first typeahead row by default
diff --git a/web/src/settings_playgrounds.ts b/web/src/settings_playgrounds.ts
index 05959e33925..4de160fee0c 100644
--- a/web/src/settings_playgrounds.ts
+++ b/web/src/settings_playgrounds.ts
@@ -165,8 +165,9 @@ function build_page(): void {
return [...language_labels.keys()];
},
helpOnEmptyStrings: true,
- item_html: (item: string): string =>
- render_typeahead_item({primary: language_labels.get(item)}),
+ item_html(_query: string): (item: string) => string {
+ return (item: string) => render_typeahead_item({primary: language_labels.get(item)});
+ },
matcher(item: string, query: string): boolean {
const q = query.trim().toLowerCase();
return item.toLowerCase().startsWith(q);
diff --git a/web/src/topic_filter_pill.ts b/web/src/topic_filter_pill.ts
index 7759ef7cd6b..88e311a4185 100644
--- a/web/src/topic_filter_pill.ts
+++ b/web/src/topic_filter_pill.ts
@@ -15,7 +15,7 @@ export type TopicFilterPill = {
export type TopicFilterPillWidget = InputPillContainer<TopicFilterPill>;
type TopicFilterTypeaheadOptions = {
- item_html: (item: TopicFilterPill, query: string) => string | undefined;
+ item_html: (query: string) => (item: TopicFilterPill) => string | undefined;
matcher: (item: TopicFilterPill, query: string) => boolean;
sorter: (items: TopicFilterPill[], query: string) => TopicFilterPill[];
stopAdvance: boolean;
@@ -48,8 +48,8 @@ export const filter_options: TopicFilterPill[] = [
export function get_typeahead_base_options(): TopicFilterTypeaheadOptions {
return {
- item_html(item: TopicFilterPill, _query: string) {
- return typeahead_helper.render_topic_state(item.label);
+ item_html(_query: string) {
+ return (item: TopicFilterPill) => typeahead_helper.render_topic_state(item.label);
},
matcher(item: TopicFilterPill, query: string) {
// This basically only matches if `is:` is in the query.
diff --git a/web/tests/composebox_typeahead.test.cjs b/web/tests/composebox_typeahead.test.cjs
index 06c838743e9..32be6a8d19a 100644
--- a/web/tests/composebox_typeahead.test.cjs
+++ b/web/tests/composebox_typeahead.test.cjs
@@ -1399,7 +1399,7 @@ test("initialize", ({override, override_rewire, mock_template}) => {
// options.item_html()
options.query = "Kro";
- actual_value = options.item_html("kronor");
+ actual_value = options.item_html()("kronor");
expected_value =
'<div class="typeahead-content">\n' +
' <div class="typeahead-text-container">\n' +
@@ -1409,7 +1409,7 @@ test("initialize", ({override, override_rewire, mock_template}) => {
// Highlighted content should be escaped.
options.query = "<";
- actual_value = options.item_html("<&>");
+ actual_value = options.item_html()("<&>");
expected_value =
'<div class="typeahead-content">\n' +
' <div class="typeahead-text-container">\n' +
@@ -1418,7 +1418,7 @@ test("initialize", ({override, override_rewire, mock_template}) => {
assert.equal(actual_value, expected_value);
options.query = "even m";
- actual_value = options.item_html("even more ice");
+ actual_value = options.item_html()("even more ice");
expected_value =
'<div class="typeahead-content">\n' +
' <div class="typeahead-text-container">\n' +
@@ -1662,7 +1662,7 @@ test("initialize", ({override, override_rewire, mock_template}) => {
// content_item_html.
ct.get_or_set_completing_for_tests("mention");
ct.get_or_set_token_for_testing("othello");
- actual_value = options.item_html(othello_item);
+ actual_value = options.item_html()(othello_item);
expected_value =
'<div class="typeahead-content">\n' +
' <div class="typeahead-image">\n' +
@@ -1679,7 +1679,7 @@ test("initialize", ({override, override_rewire, mock_template}) => {
ct.get_or_set_completing_for_tests("mention");
ct.get_or_set_token_for_testing("hamletcharacters");
- actual_value = options.item_html(hamletcharacters);
+ actual_value = options.item_html()(hamletcharacters);
expected_value =
'<div class="typeahead-content">\n' +
' <i class="typeahead-image zulip-icon zulip-icon-user-group" aria-hidden="true"></i>\n' +
@@ -2654,7 +2654,7 @@ test("content_item_html", ({override_rewire}) => {
assert.deepEqual(item, emoji);
th_render_typeahead_item_called = true;
});
- ct.content_item_html(emoji);
+ ct.content_item_html()(emoji);
ct.get_or_set_completing_for_tests("mention");
let th_render_person_called = false;
@@ -2662,14 +2662,14 @@ test("content_item_html", ({override_rewire}) => {
assert.deepEqual(person, othello_item);
th_render_person_called = true;
});
- ct.content_item_html(othello_item);
+ ct.content_item_html()(othello_item);
let th_render_user_group_called = false;
override_rewire(typeahead_helper, "render_user_group", (user_group) => {
assert.deepEqual(user_group, backend);
th_render_user_group_called = true;
});
- ct.content_item_html(backend);
+ ct.content_item_html()(backend);
// We don't have any fancy rendering for slash commands yet.
ct.get_or_set_completing_for_tests("slash");
@@ -2686,7 +2686,7 @@ test("content_item_html", ({override_rewire}) => {
});
th_render_slash_command_called = true;
});
- ct.content_item_html(me_slash);
+ ct.content_item_html()(me_slash);
ct.get_or_set_completing_for_tests("stream");
let th_render_stream_called = false;
@@ -2694,7 +2694,7 @@ test("content_item_html", ({override_rewire}) => {
assert.deepEqual(stream, denmark_stream);
th_render_stream_called = true;
});
- ct.content_item_html(denmark_stream);
+ ct.content_item_html()(denmark_stream);
ct.get_or_set_completing_for_tests("syntax");
th_render_typeahead_item_called = false;
@@ -2705,7 +2705,7 @@ test("content_item_html", ({override_rewire}) => {
});
th_render_typeahead_item_called = true;
});
- ct.content_item_html({type: "syntax", language: "py"});
+ ct.content_item_html()({type: "syntax", language: "py"});
// Verify that all stub functions have been called.
assert.ok(th_render_typeahead_item_called);
diff --git a/web/tests/pill_typeahead.test.cjs b/web/tests/pill_typeahead.test.cjs
index 42b698ee92b..3eaa961d3ad 100644
--- a/web/tests/pill_typeahead.test.cjs
+++ b/web/tests/pill_typeahead.test.cjs
@@ -196,7 +196,7 @@ run_test("set_up_user", ({mock_template, override, override_rewire}) => {
const person_query = "me";
(function test_item_html() {
- assert.equal(config.item_html(me_item, person_query), "<rendered-person-stub>");
+ assert.equal(config.item_html(person_query)(me_item), "<rendered-person-stub>");
})();
(function test_matcher() {
@@ -288,7 +288,7 @@ run_test("set_up_stream", ({mock_template, override, override_rewire}) => {
const stream_query = "#denmark";
(function test_item_html() {
- assert.equal(config.item_html(denmark_item, stream_query), "<rendered-stream-stub>");
+ assert.equal(config.item_html(stream_query)(denmark_item), "<rendered-stream-stub>");
})();
(function test_matcher() {
@@ -380,7 +380,7 @@ run_test("set_up_user_group", ({mock_template, override, override_rewire}) => {
const group_query = "testers";
(function test_item_html() {
- assert.equal(config.item_html(testers_item, group_query), "<rendered-group-stub>");
+ assert.equal(config.item_html(group_query)(testers_item), "<rendered-group-stub>");
})();
(function test_matcher() {
@@ -486,21 +486,21 @@ run_test("set_up_combined", ({mock_template, override, override_rewire}) => {
if (opts.stream) {
// Test stream item_html for widgets that allow stream pills.
assert.equal(
- config.item_html(denmark_item, stream_query),
+ config.item_html(stream_query)(denmark_item),
"<rendered-stream-stub>",
);
}
if (opts.user_group && opts.user) {
// If user is also allowed along with user_group
// then we should check that each of them rendered correctly.
- assert.equal(config.item_html(testers_item, group_query), "<rendered-group-stub>");
- assert.equal(config.item_html(me_item, person_query), "<rendered-person-stub>");
+ assert.equal(config.item_html(group_query)(testers_item), "<rendered-group-stub>");
+ assert.equal(config.item_html(person_query)(me_item), "<rendered-person-stub>");
}
if (opts.user && !opts.user_group) {
- assert.equal(config.item_html(me_item, person_query), "<rendered-person-stub>");
+ assert.equal(config.item_html(person_query)(me_item), "<rendered-person-stub>");
}
if (!opts.user && opts.user_group) {
- assert.equal(config.item_html(testers_item, group_query), "<rendered-group-stub>");
+ assert.equal(config.item_html(group_query)(testers_item), "<rendered-group-stub>");
}
})();
@@ -794,8 +794,8 @@ run_test("set_up_group_setting_typeahead", ({mock_template, override, override_r
(function test_item_html() {
// If user is also allowed along with user_group
// then we should check that each of them rendered correctly.
- assert.equal(config.item_html(testers_item, group_query), "<rendered-group-stub>");
- assert.equal(config.item_html(me_item, person_query), "<rendered-person-stub>");
+ assert.equal(config.item_html(group_query)(testers_item), "<rendered-group-stub>");
+ assert.equal(config.item_html(person_query)(me_item), "<rendered-person-stub>");
})();
(function test_matcher() {
diff --git a/web/tests/search.test.cjs b/web/tests/search.test.cjs
index c2b7ba313ed..c53b29d1f1d 100644
--- a/web/tests/search.test.cjs
+++ b/web/tests/search.test.cjs
@@ -101,10 +101,10 @@ run_test("initialize", ({override, override_rewire, mock_template}) => {
/* Test highlighter */
let expected_value = `<div class="search_list_item">\n <div class="description">Search for dm</div>\n \n</div>\n`;
- assert.equal(opts.item_html(search_suggestions[0], "dm"), expected_value);
+ assert.equal(opts.item_html("dm")(search_suggestions[0]), expected_value);
expected_value = `<div class="search_list_item">\n <span class="pill-container"><div class='pill ' tabindex=0>\n <span class="pill-label">\n <span class="pill-value">\ndm:\n </span></span>\n <div class="exit">\n <a role="button" class="zulip-icon zulip-icon-close pill-close-button"></a>\n </div>\n</div>\n</span>\n <div class="description">Direct messages with</div>\n</div>\n`;
- assert.equal(opts.item_html(search_suggestions[1], "dm"), expected_value);
+ assert.equal(opts.item_html("dm")(search_suggestions[1]), expected_value);
/* Test sorter */
assert.equal(opts.sorter(search_suggestions.strings), search_suggestions.strings);
@@ -116,12 +116,12 @@ run_test("initialize", ({override, override_rewire, mock_template}) => {
/* Test highlighter */
let description_html = "Search for ver";
let expected_value = `<div class="search_list_item">\n <div class="description">Search for ver</div>\n \n</div>\n`;
- assert.equal(opts.item_html(search_suggestions[0], "ver"), expected_value);
+ assert.equal(opts.item_html("ver")(search_suggestions[0]), expected_value);
const search_string = "channel: Verona";
description_html = "Messages in #Verona";
expected_value = `<div class="search_list_item">\n <span class="pill-container"><div class='pill ' tabindex=0>\n <span class="pill-label">\n <span class="pill-value">\n${search_string}\n </span></span>\n <div class="exit">\n <a role="button" class="zulip-icon zulip-icon-close pill-close-button"></a>\n </div>\n</div>\n</span>\n <div class="description">${description_html}</div>\n</div>\n`;
- assert.equal(opts.item_html(search_suggestions[1], "ver"), expected_value);
+ assert.equal(opts.item_html("ver")(search_suggestions[1]), expected_value);
/* Test sorter */
assert.equal(opts.sorter(search_suggestions.strings), search_suggestions.strings);
@@ -138,17 +138,17 @@ run_test("initialize", ({override, override_rewire, mock_template}) => {
/* Test highlighter */
const description_html = "Search for zo";
let expected_value = `<div class="search_list_item">\n <div class="description">${description_html}</div>\n \n</div>\n`;
- assert.equal(opts.item_html(search_suggestions[0], "zo"), expected_value);
+ assert.equal(opts.item_html("zo")(search_suggestions[0]), expected_value);
override(realm, "realm_enable_guest_user_indicator", true);
expected_value = `<div class="search_list_item">\n <span class="pill-container"><div class="user-pill-container pill" tabindex=0>\n <span class="pill-label">sender:\n </span>\n <div class="pill" data-user-id="3">\n <img class="pill-image" src="/avatar/3" />\n <div class="pill-image-border"></div>\n <span class="pill-label">\n <span class="pill-value">Zoe</span></span>\n <div class="exit">\n <a role="button" class="zulip-icon zulip-icon-close pill-close-button"></a>\n </div>\n </div>\n</div>\n</span>\n \n</div>\n`;
- assert.equal(opts.item_html(search_suggestions[1], "zo"), expected_value);
+ assert.equal(opts.item_html("zo")(search_suggestions[1]), expected_value);
expected_value = `<div class="search_list_item">\n <span class="pill-container"><div class="user-pill-container pill" tabindex=0>\n <span class="pill-label">dm:\n </span>\n <div class="pill" data-user-id="3">\n <img class="pill-image" src="/avatar/3" />\n <div class="pill-image-border"></div>\n <span class="pill-label">\n <span class="pill-value">Zoe</span></span>\n <div class="exit">\n <a role="button" class="zulip-icon zulip-icon-close pill-close-button"></a>\n </div>\n </div>\n</div>\n</span>\n \n</div>\n`;
- assert.equal(opts.item_html(search_suggestions[2], "zo"), expected_value);
+ assert.equal(opts.item_html("zo")(search_suggestions[2]), expected_value);
expected_value = `<div class="search_list_item">\n <span class="pill-container"><div class="user-pill-container pill" tabindex=0>\n <span class="pill-label">dm-including:\n </span>\n <div class="pill" data-user-id="3">\n <img class="pill-image" src="/avatar/3" />\n <div class="pill-image-border"></div>\n <span class="pill-label">\n <span class="pill-value">Zoe</span></span>\n <div class="exit">\n <a role="button" class="zulip-icon zulip-icon-close pill-close-button"></a>\n </div>\n </div>\n</div>\n</span>\n \n</div>\n`;
- assert.equal(opts.item_html(search_suggestions[3], "zo"), expected_value);
+ assert.equal(opts.item_html("zo")(search_suggestions[3]), expected_value);
/* Test sorter */
assert.equal(opts.sorter(search_suggestions.strings), search_suggestions.strings);