mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	topic_link_util: Add support for empty topics in the frontend.
Though the frontend module generated correct urls for empty topics, it would sometime generate incorrect link text in the fallback md link syntax. (eg, if empty string was provided as the topic name). This commit fixes that.
This commit is contained in:
		@@ -13,6 +13,9 @@ mock_esm("../src/user_settings", {
 | 
			
		||||
        web_channel_default_view: settings_config.web_channel_default_view_values.channel_feed.code,
 | 
			
		||||
    },
 | 
			
		||||
});
 | 
			
		||||
mock_esm("../src/state_data", {
 | 
			
		||||
    realm: {realm_empty_topic_display_name: "general chat"},
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const sweden_stream = {
 | 
			
		||||
    name: "Sweden",
 | 
			
		||||
@@ -125,6 +128,23 @@ run_test("stream_topic_link_syntax_test", () => {
 | 
			
		||||
        "[#Sweden > &a[b](#narrow/channel/1-Sweden/topic/.26a.5Bb)",
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    assert.equal(topic_link_util.get_stream_topic_link_syntax("Sweden", ""), "#**Sweden>**");
 | 
			
		||||
 | 
			
		||||
    assert.equal(
 | 
			
		||||
        topic_link_util.get_stream_topic_link_syntax("$$MONEY$$", ""),
 | 
			
		||||
        "[#$$MONEY$$ > translated: general chat](#narrow/channel/6-.24.24MONEY.24.24/topic/)",
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    assert.equal(
 | 
			
		||||
        topic_link_util.get_fallback_markdown_link("Sweden", "abc", 123),
 | 
			
		||||
        "[#Sweden > abc @ 💬](#narrow/channel/1-Sweden/topic/abc/near/123)",
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    assert.equal(
 | 
			
		||||
        topic_link_util.get_fallback_markdown_link("Sweden", "", 123),
 | 
			
		||||
        "[#Sweden > translated: general chat @ 💬](#narrow/channel/1-Sweden/topic//near/123)",
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    // Only for full coverage of the module.
 | 
			
		||||
    assert.equal(topic_link_util.escape_invalid_stream_topic_characters("Sweden"), "Sweden");
 | 
			
		||||
    assert.equal(
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user