mirror of https://github.com/zulip/zulip.git
rendered_markdown: Fix stream-topic parser.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
65c400e06d
commit
eae05ba0ae
|
@ -148,19 +148,19 @@ run_test("stream-links", () => {
|
|||
const $stream_topic = $.create("a.stream-topic");
|
||||
$stream_topic.set_find_results(".highlight", false);
|
||||
$stream_topic.attr("data-stream-id", stream.stream_id);
|
||||
$stream_topic.text("#random>topic name");
|
||||
$stream_topic.text("#random > topic name > still the topic name");
|
||||
$content.set_find_results("a.stream", $array([$stream]));
|
||||
$content.set_find_results("a.stream-topic", $array([$stream_topic]));
|
||||
|
||||
// Initial asserts
|
||||
assert.equal($stream.text(), "never-been-set");
|
||||
assert.equal($stream_topic.text(), "#random>topic name");
|
||||
assert.equal($stream_topic.text(), "#random > topic name > still the topic name");
|
||||
|
||||
rm.update_elements($content);
|
||||
|
||||
// Final asserts
|
||||
assert.equal($stream.text(), `#${stream.name}`);
|
||||
assert.equal($stream_topic.text(), `#${stream.name} > topic name`);
|
||||
assert.equal($stream_topic.text(), `#${stream.name} > topic name > still the topic name`);
|
||||
});
|
||||
|
||||
run_test("timestamp", () => {
|
||||
|
|
|
@ -142,14 +142,13 @@ export const update_elements = (content) => {
|
|||
if (stream_id && !$(this).find(".highlight").length) {
|
||||
// Display the current name for stream if it is not
|
||||
// being displayed in search highlight.
|
||||
const text = $(this).text();
|
||||
const topic = text.split(">", 2)[1];
|
||||
const stream_name = stream_data.maybe_get_stream_name(stream_id);
|
||||
if (stream_name !== undefined) {
|
||||
// If the stream has been deleted,
|
||||
// stream_data.maybe_get_stream_name might return
|
||||
// undefined. Otherwise, display the current stream name.
|
||||
$(this).text("#" + stream_name + " > " + topic);
|
||||
const text = $(this).text();
|
||||
$(this).text("#" + stream_name + text.slice(text.indexOf(" > ")));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue