pill_typeahead: Use query passed to source instead hacky this.

This commit is contained in:
evykassirer 2024-03-24 20:44:51 -07:00 committed by Tim Abbott
parent b4299d99fd
commit 9f83d14fb7
2 changed files with 4 additions and 4 deletions

View File

@ -40,9 +40,9 @@ export function set_up($input, pills, opts) {
items: 5, items: 5,
fixed: true, fixed: true,
dropup: true, dropup: true,
source() { source(query) {
let source = []; let source = [];
if (include_streams(this.query)) { if (include_streams(query)) {
// If query starts with # we expect, // If query starts with # we expect,
// only stream suggestions so we simply // only stream suggestions so we simply
// return stream source. // return stream source.

View File

@ -251,7 +251,7 @@ run_test("set_up", ({mock_template, override}) => {
(function test_source() { (function test_source() {
let result; let result;
if (opts.stream) { if (opts.stream) {
result = config.source.call(fake_stream_this); result = config.source(fake_stream_this.query);
const stream_ids = result.map((stream) => stream.stream_id); const stream_ids = result.map((stream) => stream.stream_id);
const expected_stream_ids = [denmark.stream_id, sweden.stream_id]; const expected_stream_ids = [denmark.stream_id, sweden.stream_id];
assert.deepEqual(stream_ids, expected_stream_ids); assert.deepEqual(stream_ids, expected_stream_ids);
@ -262,7 +262,7 @@ run_test("set_up", ({mock_template, override}) => {
function is_group(item) { function is_group(item) {
return item.members; return item.members;
} }
result = config.source.call(fake_person_this); result = config.source(fake_person_this.query);
actual_result = result actual_result = result
.map((item) => { .map((item) => {
if (is_group(item)) { if (is_group(item)) {