js: Reformat with Prettier.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-07-14 15:34:28 -07:00
committed by Tim Abbott
parent bd45216c21
commit b65d2e063d
301 changed files with 7829 additions and 6687 deletions

View File

@@ -21,21 +21,16 @@ set_global("moment", require("moment-timezone"));
set_global("page_params", {
realm_users: [],
realm_emoji: {
1: {id: 1,
1: {
id: 1,
name: "burrito",
source_url: "/static/generated/emoji/images/emoji/burrito.png",
deactivated: false,
},
},
realm_filters: [
[
"#(?P<id>[0-9]{2,8})",
"https://trac.example.com/ticket/%(id)s",
],
[
"ZBUG_(?P<id>[0-9]{2,8})",
"https://trac2.zulip.net/ticket/%(id)s",
],
["#(?P<id>[0-9]{2,8})", "https://trac.example.com/ticket/%(id)s"],
["ZBUG_(?P<id>[0-9]{2,8})", "https://trac2.zulip.net/ticket/%(id)s"],
[
"ZGROUP_(?P<id>[0-9]{2,8}):(?P<zone>[0-9]{1,8})",
"https://zone_%(zone)s.zulip.net/ticket/%(id)s",
@@ -182,15 +177,13 @@ stream_data.add_sub(amp_stream);
// works properly before markdown is initialized.
run_test("fenced_block_defaults", () => {
const input = "\n```\nfenced code\n```\n\nand then after\n";
const expected = '\n\n<div class="codehilite"><pre><span></span><code>fenced code\n</code></pre></div>\n\n\n\nand then after\n\n';
const expected =
'\n\n<div class="codehilite"><pre><span></span><code>fenced code\n</code></pre></div>\n\n\n\nand then after\n\n';
const output = fenced_code.process_fenced_code(input);
assert.equal(output, expected);
});
markdown.initialize(
page_params.realm_filters,
markdown_config.get_helpers(),
);
markdown.initialize(page_params.realm_filters, markdown_config.get_helpers());
const markdown_data = global.read_fixture_data("markdown_test_cases.json");
@@ -206,7 +199,7 @@ run_test("markdown_detection", () => {
"No user mention **leo**",
"No user mention @what there",
"No group mention *hamletcharacters*",
"We like to code\n~~~\ndef code():\n we = \"like to do\"\n~~~",
'We like to code\n~~~\ndef code():\n we = "like to do"\n~~~',
"This is a\nmultiline :emoji: here\n message",
"This is an :emoji: message",
"User Mention @**leo**",
@@ -244,7 +237,6 @@ run_test("marked_shared", () => {
const tests = markdown_data.regular_tests;
tests.forEach((test) => {
// Ignore tests if specified
if (test.ignore === true) {
return;
@@ -288,126 +280,245 @@ run_test("marked", () => {
{input: "hello", expected: "<p>hello</p>"},
{input: "hello there", expected: "<p>hello there</p>"},
{input: "hello **bold** for you", expected: "<p>hello <strong>bold</strong> for you</p>"},
{input: "hello ***foo*** for you", expected: "<p>hello <strong><em>foo</em></strong> for you</p>"},
{
input: "hello ***foo*** for you",
expected: "<p>hello <strong><em>foo</em></strong> for you</p>",
},
{input: "__hello__", expected: "<p>__hello__</p>"},
{input: "\n```\nfenced code\n```\n\nand then after\n",
expected: '<div class="codehilite"><pre><span></span><code>fenced code\n</code></pre></div>\n\n\n<p>and then after</p>'},
{input: "\n```\n fenced code trailing whitespace \n```\n\nand then after\n",
expected: '<div class="codehilite"><pre><span></span><code> fenced code trailing whitespace\n</code></pre></div>\n\n\n<p>and then after</p>'},
{input: "* a\n* list \n* here",
expected: "<ul>\n<li>a</li>\n<li>list </li>\n<li>here</li>\n</ul>"},
{input: "\n```c#\nfenced code special\n```\n\nand then after\n",
expected: '<div class="codehilite"><pre><span></span><code>fenced code special\n</code></pre></div>\n\n\n<p>and then after</p>'},
{input: "\n```vb.net\nfenced code dot\n```\n\nand then after\n",
expected: '<div class="codehilite"><pre><span></span><code>fenced code dot\n</code></pre></div>\n\n\n<p>and then after</p>'},
{input: "Some text first\n* a\n* list \n* here\n\nand then after",
expected: "<p>Some text first</p>\n<ul>\n<li>a</li>\n<li>list </li>\n<li>here</li>\n</ul>\n<p>and then after</p>"},
{input: "1. an\n2. ordered \n3. list",
expected: "<ol>\n<li>an</li>\n<li>ordered </li>\n<li>list</li>\n</ol>"},
{input: "\n~~~quote\nquote this for me\n~~~\nthanks\n",
expected: "<blockquote>\n<p>quote this for me</p>\n</blockquote>\n<p>thanks</p>"},
{input: "This is a @**CordeLIA Lear** mention",
expected: '<p>This is a <span class="user-mention" data-user-id="101">@Cordelia Lear</span> mention</p>'},
{input: "These @ @**** are not mentions",
expected: "<p>These @ @<em>**</em> are not mentions</p>"},
{input: "These # #**** are not mentions",
expected: "<p>These # #<em>**</em> are not mentions</p>"},
{input: "These @* are not mentions",
expected: "<p>These @* are not mentions</p>"},
{input: "These #* #*** are also not mentions",
expected: "<p>These #* #*** are also not mentions</p>"},
{input: "This is a #**Denmark** stream link",
expected: '<p>This is a <a class="stream" data-stream-id="1" href="/#narrow/stream/1-Denmark">#Denmark</a> stream link</p>'},
{input: "This is #**Denmark** and #**social** stream links",
expected: '<p>This is <a class="stream" data-stream-id="1" href="/#narrow/stream/1-Denmark">#Denmark</a> and <a class="stream" data-stream-id="2" href="/#narrow/stream/2-social">#social</a> stream links</p>'},
{input: "And this is a #**wrong** stream link",
expected: "<p>And this is a #**wrong** stream link</p>"},
{input: "This is a #**Denmark>some topic** stream_topic link",
expected: '<p>This is a <a class="stream-topic" data-stream-id="1" href="/#narrow/stream/1-Denmark/topic/some.20topic">#Denmark > some topic</a> stream_topic link</p>'},
{input: "This has two links: #**Denmark>some topic** and #**social>other topic**.",
expected: '<p>This has two links: <a class="stream-topic" data-stream-id="1" href="/#narrow/stream/1-Denmark/topic/some.20topic">#Denmark > some topic</a> and <a class="stream-topic" data-stream-id="2" href="/#narrow/stream/2-social/topic/other.20topic">#social > other topic</a>.</p>'},
{input: "This is not a #**Denmark>** stream_topic link",
expected: "<p>This is not a #**Denmark&gt;** stream_topic link</p>"},
{input: "mmm...:burrito:s",
expected: '<p>mmm...<img alt=":burrito:" class="emoji" src="/static/generated/emoji/images/emoji/burrito.png" title="burrito">s</p>'},
{input: "This is an :poop: message",
expected: '<p>This is an <span aria-label="poop" class="emoji emoji-1f4a9" role="img" title="poop">:poop:</span> message</p>'},
{input: "\ud83d\udca9",
expected: '<p><span aria-label="poop" class="emoji emoji-1f4a9" role="img" title="poop">:poop:</span></p>'},
{input: "\u{1f6b2}",
expected: "<p>\u{1f6b2}</p>"},
{input: "Silent mention: @_**Cordelia Lear**",
expected: '<p>Silent mention: <span class="user-mention silent" data-user-id="101">Cordelia Lear</span></p>'},
{input: "> Mention in quote: @**Cordelia Lear**\n\nMention outside quote: @**Cordelia Lear**",
expected: '<blockquote>\n<p>Mention in quote: <span class="user-mention silent" data-user-id="101">Cordelia Lear</span></p>\n</blockquote>\n<p>Mention outside quote: <span class="user-mention" data-user-id="101">@Cordelia Lear</span></p>'},
{
input: "\n```\nfenced code\n```\n\nand then after\n",
expected:
'<div class="codehilite"><pre><span></span><code>fenced code\n</code></pre></div>\n\n\n<p>and then after</p>',
},
{
input:
"\n```\n fenced code trailing whitespace \n```\n\nand then after\n",
expected:
'<div class="codehilite"><pre><span></span><code> fenced code trailing whitespace\n</code></pre></div>\n\n\n<p>and then after</p>',
},
{
input: "* a\n* list \n* here",
expected: "<ul>\n<li>a</li>\n<li>list </li>\n<li>here</li>\n</ul>",
},
{
input: "\n```c#\nfenced code special\n```\n\nand then after\n",
expected:
'<div class="codehilite"><pre><span></span><code>fenced code special\n</code></pre></div>\n\n\n<p>and then after</p>',
},
{
input: "\n```vb.net\nfenced code dot\n```\n\nand then after\n",
expected:
'<div class="codehilite"><pre><span></span><code>fenced code dot\n</code></pre></div>\n\n\n<p>and then after</p>',
},
{
input: "Some text first\n* a\n* list \n* here\n\nand then after",
expected:
"<p>Some text first</p>\n<ul>\n<li>a</li>\n<li>list </li>\n<li>here</li>\n</ul>\n<p>and then after</p>",
},
{
input: "1. an\n2. ordered \n3. list",
expected: "<ol>\n<li>an</li>\n<li>ordered </li>\n<li>list</li>\n</ol>",
},
{
input: "\n~~~quote\nquote this for me\n~~~\nthanks\n",
expected: "<blockquote>\n<p>quote this for me</p>\n</blockquote>\n<p>thanks</p>",
},
{
input: "This is a @**CordeLIA Lear** mention",
expected:
'<p>This is a <span class="user-mention" data-user-id="101">@Cordelia Lear</span> mention</p>',
},
{
input: "These @ @**** are not mentions",
expected: "<p>These @ @<em>**</em> are not mentions</p>",
},
{
input: "These # #**** are not mentions",
expected: "<p>These # #<em>**</em> are not mentions</p>",
},
{input: "These @* are not mentions", expected: "<p>These @* are not mentions</p>"},
{
input: "These #* #*** are also not mentions",
expected: "<p>These #* #*** are also not mentions</p>",
},
{
input: "This is a #**Denmark** stream link",
expected:
'<p>This is a <a class="stream" data-stream-id="1" href="/#narrow/stream/1-Denmark">#Denmark</a> stream link</p>',
},
{
input: "This is #**Denmark** and #**social** stream links",
expected:
'<p>This is <a class="stream" data-stream-id="1" href="/#narrow/stream/1-Denmark">#Denmark</a> and <a class="stream" data-stream-id="2" href="/#narrow/stream/2-social">#social</a> stream links</p>',
},
{
input: "And this is a #**wrong** stream link",
expected: "<p>And this is a #**wrong** stream link</p>",
},
{
input: "This is a #**Denmark>some topic** stream_topic link",
expected:
'<p>This is a <a class="stream-topic" data-stream-id="1" href="/#narrow/stream/1-Denmark/topic/some.20topic">#Denmark > some topic</a> stream_topic link</p>',
},
{
input: "This has two links: #**Denmark>some topic** and #**social>other topic**.",
expected:
'<p>This has two links: <a class="stream-topic" data-stream-id="1" href="/#narrow/stream/1-Denmark/topic/some.20topic">#Denmark > some topic</a> and <a class="stream-topic" data-stream-id="2" href="/#narrow/stream/2-social/topic/other.20topic">#social > other topic</a>.</p>',
},
{
input: "This is not a #**Denmark>** stream_topic link",
expected: "<p>This is not a #**Denmark&gt;** stream_topic link</p>",
},
{
input: "mmm...:burrito:s",
expected:
'<p>mmm...<img alt=":burrito:" class="emoji" src="/static/generated/emoji/images/emoji/burrito.png" title="burrito">s</p>',
},
{
input: "This is an :poop: message",
expected:
'<p>This is an <span aria-label="poop" class="emoji emoji-1f4a9" role="img" title="poop">:poop:</span> message</p>',
},
{
input: "\ud83d\udca9",
expected:
'<p><span aria-label="poop" class="emoji emoji-1f4a9" role="img" title="poop">:poop:</span></p>',
},
{input: "\u{1f6b2}", expected: "<p>\u{1f6b2}</p>"},
{
input: "Silent mention: @_**Cordelia Lear**",
expected:
'<p>Silent mention: <span class="user-mention silent" data-user-id="101">Cordelia Lear</span></p>',
},
{
input:
"> Mention in quote: @**Cordelia Lear**\n\nMention outside quote: @**Cordelia Lear**",
expected:
'<blockquote>\n<p>Mention in quote: <span class="user-mention silent" data-user-id="101">Cordelia Lear</span></p>\n</blockquote>\n<p>Mention outside quote: <span class="user-mention" data-user-id="101">@Cordelia Lear</span></p>',
},
// Test only those realm filters which don't return True for
// `contains_backend_only_syntax()`. Those which return True
// are tested separately.
{input: "This is a realm filter #1234 with text after it",
expected: '<p>This is a realm filter <a href="https://trac.example.com/ticket/1234" title="https://trac.example.com/ticket/1234">#1234</a> with text after it</p>'},
{input: "#1234is not a realm filter.",
expected: "<p>#1234is not a realm filter.</p>"},
{input: "A pattern written as #1234is not a realm filter.",
expected: "<p>A pattern written as #1234is not a realm filter.</p>"},
{input: "This is a realm filter with ZGROUP_123:45 groups",
expected: '<p>This is a realm filter with <a href="https://zone_45.zulip.net/ticket/123" title="https://zone_45.zulip.net/ticket/123">ZGROUP_123:45</a> groups</p>'},
{input: "Test *italic*",
expected: "<p>Test <em>italic</em></p>"},
{input: "T\n#**Denmark**",
expected: '<p>T<br>\n<a class="stream" data-stream-id="1" href="/#narrow/stream/1-Denmark">#Denmark</a></p>'},
{input: "T\n@**Cordelia Lear**",
expected: '<p>T<br>\n<span class="user-mention" data-user-id="101">@Cordelia Lear</span></p>'},
{input: "@**Mark Twin|104** and @**Mark Twin|105** are out to confuse you.",
expected: '<p><span class="user-mention" data-user-id="104">@Mark Twin</span> and <span class="user-mention" data-user-id="105">@Mark Twin</span> are out to confuse you.</p>'},
{input: "@**Invalid User|1234**",
expected: "<p>@**Invalid User|1234**</p>"},
{input: "@**Cordelia LeAR|103** has a wrong user_id.",
expected: "<p>@**Cordelia LeAR|103** has a wrong user_id.</p>"},
{input: "@**Brother of Bobby|123** is really the full name.",
expected: '<p><span class="user-mention" data-user-id="106">@Brother of Bobby|123</span> is really the full name.</p>'},
{input: "@**Brother of Bobby|123|106**",
expected: '<p><span class="user-mention" data-user-id="106">@Brother of Bobby|123</span></p>'},
{input: "T\n@hamletcharacters",
expected: "<p>T<br>\n@hamletcharacters</p>"},
{input: "T\n@*hamletcharacters*",
expected: '<p>T<br>\n<span class="user-group-mention" data-user-group-id="1">@hamletcharacters</span></p>'},
{input: "T\n@*notagroup*",
expected: "<p>T<br>\n@*notagroup*</p>"},
{input: "T\n@*backend*",
expected: '<p>T<br>\n<span class="user-group-mention" data-user-group-id="2">@Backend</span></p>'},
{input: "@*notagroup*",
expected: "<p>@*notagroup*</p>"},
{input: "This is a realm filter `hello` with text after it",
expected: "<p>This is a realm filter <code>hello</code> with text after it</p>"},
{
input: "This is a realm filter #1234 with text after it",
expected:
'<p>This is a realm filter <a href="https://trac.example.com/ticket/1234" title="https://trac.example.com/ticket/1234">#1234</a> with text after it</p>',
},
{input: "#1234is not a realm filter.", expected: "<p>#1234is not a realm filter.</p>"},
{
input: "A pattern written as #1234is not a realm filter.",
expected: "<p>A pattern written as #1234is not a realm filter.</p>",
},
{
input: "This is a realm filter with ZGROUP_123:45 groups",
expected:
'<p>This is a realm filter with <a href="https://zone_45.zulip.net/ticket/123" title="https://zone_45.zulip.net/ticket/123">ZGROUP_123:45</a> groups</p>',
},
{input: "Test *italic*", expected: "<p>Test <em>italic</em></p>"},
{
input: "T\n#**Denmark**",
expected:
'<p>T<br>\n<a class="stream" data-stream-id="1" href="/#narrow/stream/1-Denmark">#Denmark</a></p>',
},
{
input: "T\n@**Cordelia Lear**",
expected:
'<p>T<br>\n<span class="user-mention" data-user-id="101">@Cordelia Lear</span></p>',
},
{
input: "@**Mark Twin|104** and @**Mark Twin|105** are out to confuse you.",
expected:
'<p><span class="user-mention" data-user-id="104">@Mark Twin</span> and <span class="user-mention" data-user-id="105">@Mark Twin</span> are out to confuse you.</p>',
},
{input: "@**Invalid User|1234**", expected: "<p>@**Invalid User|1234**</p>"},
{
input: "@**Cordelia LeAR|103** has a wrong user_id.",
expected: "<p>@**Cordelia LeAR|103** has a wrong user_id.</p>",
},
{
input: "@**Brother of Bobby|123** is really the full name.",
expected:
'<p><span class="user-mention" data-user-id="106">@Brother of Bobby|123</span> is really the full name.</p>',
},
{
input: "@**Brother of Bobby|123|106**",
expected:
'<p><span class="user-mention" data-user-id="106">@Brother of Bobby|123</span></p>',
},
{input: "T\n@hamletcharacters", expected: "<p>T<br>\n@hamletcharacters</p>"},
{
input: "T\n@*hamletcharacters*",
expected:
'<p>T<br>\n<span class="user-group-mention" data-user-group-id="1">@hamletcharacters</span></p>',
},
{input: "T\n@*notagroup*", expected: "<p>T<br>\n@*notagroup*</p>"},
{
input: "T\n@*backend*",
expected:
'<p>T<br>\n<span class="user-group-mention" data-user-group-id="2">@Backend</span></p>',
},
{input: "@*notagroup*", expected: "<p>@*notagroup*</p>"},
{
input: "This is a realm filter `hello` with text after it",
expected: "<p>This is a realm filter <code>hello</code> with text after it</p>",
},
// Test the emoticon conversion
{input: ":)",
expected: "<p>:)</p>"},
{input: ":)",
expected: '<p><span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>',
translate_emoticons: true},
{input: ":)", expected: "<p>:)</p>"},
{
input: ":)",
expected:
'<p><span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>',
translate_emoticons: true,
},
// Test HTML Escape in Custom Zulip Rules
{input: "@**<h1>The Rogue One</h1>**",
expected: "<p>@**&lt;h1&gt;The Rogue One&lt;/h1&gt;**</p>"},
{input: "#**<h1>The Rogue One</h1>**",
expected: "<p>#**&lt;h1&gt;The Rogue One&lt;/h1&gt;**</p>"},
{input: ":<h1>The Rogue One</h1>:",
expected: "<p>:&lt;h1&gt;The Rogue One&lt;/h1&gt;:</p>"},
{input: "@**O'Connell**",
expected: "<p>@**O&#39;Connell**</p>"},
{input: "@*Bobby <h1>Tables</h1>*",
expected: '<p><span class="user-group-mention" data-user-group-id="3">@Bobby &lt;h1&gt;Tables&lt;/h1&gt;</span></p>'},
{input: "@*& &amp; &amp;amp;*",
expected: '<p><span class="user-group-mention" data-user-group-id="4">@&amp; &amp; &amp;amp;</span></p>'},
{input: "@**Bobby <h1>Tables</h1>**",
expected: '<p><span class="user-mention" data-user-id="103">@Bobby &lt;h1&gt;Tables&lt;/h1&gt;</span></p>'},
{input: "@**& &amp; &amp;amp;**",
expected: '<p><span class="user-mention" data-user-id="107">@&amp; &amp; &amp;amp;</span></p>'},
{input: "#**Bobby <h1>Tables</h1>**",
expected: '<p><a class="stream-topic" data-stream-id="4" href="/#narrow/stream/4-Bobby-.3Ch1/topic/Tables.3C.2Fh1.3E">#Bobby &lt;h1 > Tables&lt;/h1&gt;</a></p>'},
{input: "#**& &amp; &amp;amp;**",
expected: '<p><a class="stream" data-stream-id="5" href="/#narrow/stream/5-.26-.26.20.26amp.3B">#&amp; &amp; &amp;amp;</a></p>'},
{input: "#**& &amp; &amp;amp;>& &amp; &amp;amp;**",
expected: '<p><a class="stream-topic" data-stream-id="5" href="/#narrow/stream/5-.26-.26.20.26amp.3B/topic/.26.20.26.20.26amp.3B">#&amp; &amp; &amp;amp; > &amp; &amp; &amp;amp;</a></p>'},
{
input: "@**<h1>The Rogue One</h1>**",
expected: "<p>@**&lt;h1&gt;The Rogue One&lt;/h1&gt;**</p>",
},
{
input: "#**<h1>The Rogue One</h1>**",
expected: "<p>#**&lt;h1&gt;The Rogue One&lt;/h1&gt;**</p>",
},
{
input: ":<h1>The Rogue One</h1>:",
expected: "<p>:&lt;h1&gt;The Rogue One&lt;/h1&gt;:</p>",
},
{input: "@**O'Connell**", expected: "<p>@**O&#39;Connell**</p>"},
{
input: "@*Bobby <h1>Tables</h1>*",
expected:
'<p><span class="user-group-mention" data-user-group-id="3">@Bobby &lt;h1&gt;Tables&lt;/h1&gt;</span></p>',
},
{
input: "@*& &amp; &amp;amp;*",
expected:
'<p><span class="user-group-mention" data-user-group-id="4">@&amp; &amp; &amp;amp;</span></p>',
},
{
input: "@**Bobby <h1>Tables</h1>**",
expected:
'<p><span class="user-mention" data-user-id="103">@Bobby &lt;h1&gt;Tables&lt;/h1&gt;</span></p>',
},
{
input: "@**& &amp; &amp;amp;**",
expected:
'<p><span class="user-mention" data-user-id="107">@&amp; &amp; &amp;amp;</span></p>',
},
{
input: "#**Bobby <h1>Tables</h1>**",
expected:
'<p><a class="stream-topic" data-stream-id="4" href="/#narrow/stream/4-Bobby-.3Ch1/topic/Tables.3C.2Fh1.3E">#Bobby &lt;h1 > Tables&lt;/h1&gt;</a></p>',
},
{
input: "#**& &amp; &amp;amp;**",
expected:
'<p><a class="stream" data-stream-id="5" href="/#narrow/stream/5-.26-.26.20.26amp.3B">#&amp; &amp; &amp;amp;</a></p>',
},
{
input: "#**& &amp; &amp;amp;>& &amp; &amp;amp;**",
expected:
'<p><a class="stream-topic" data-stream-id="5" href="/#narrow/stream/5-.26-.26.20.26amp.3B/topic/.26.20.26.20.26amp.3B">#&amp; &amp; &amp;amp; > &amp; &amp; &amp;amp;</a></p>',
},
];
// We remove one of the unicode emoji we put as input in one of the test
@@ -568,12 +679,17 @@ run_test("python_to_js_filter", () => {
let expected_value = [/\/aa\/g(?![\w])/gim, /\/aa\/g(?![\w])/g];
assert.deepEqual(actual_value, expected_value);
// Test case with multiple replacements.
markdown.update_realm_filter_rules([["#cf(?P<contest>[0-9]+)(?P<problem>[A-Z][0-9A-Z]*)", "http://google.com"]]);
markdown.update_realm_filter_rules([
["#cf(?P<contest>[0-9]+)(?P<problem>[A-Z][0-9A-Z]*)", "http://google.com"],
]);
actual_value = marked.InlineLexer.rules.zulip.realm_filters;
expected_value = [/#cf([0-9]+)([A-Z][0-9A-Z]*)(?![\w])/g];
assert.deepEqual(actual_value, expected_value);
// Test incorrect syntax.
blueslip.expect("error", "python_to_js_filter: Invalid regular expression: /!@#@(!#&((!&(@#((?![\\w])/: Unterminated group");
blueslip.expect(
"error",
"python_to_js_filter: Invalid regular expression: /!@#@(!#&((!&(@#((?![\\w])/: Unterminated group",
);
markdown.update_realm_filter_rules([["!@#@(!#&((!&(@#(", "http://google.com"]]);
actual_value = marked.InlineLexer.rules.zulip.realm_filters;
expected_value = [];
@@ -581,7 +697,9 @@ run_test("python_to_js_filter", () => {
});
run_test("katex_throws_unexpected_exceptions", () => {
katex.renderToString = function () { throw new Error("some-exception"); };
katex.renderToString = function () {
throw new Error("some-exception");
};
blueslip.expect("error", "Error: some-exception");
const message = {raw_content: "$$a$$"};
markdown.apply_markdown(message);
@@ -605,9 +723,21 @@ run_test("translate_emoticons_to_names", () => {
{name: "symbol at start", original: "Hello,<original>", expected: "Hello,<converted>"},
{name: "after a word", original: "Hello<original>", expected: "Hello<original>"},
{name: "between words", original: "Hello<original>World", expected: "Hello<original>World"},
{name: "end of sentence", original: "End of sentence. <original>", expected: "End of sentence. <converted>"},
{name: "between symbols", original: "Hello.<original>! World.", expected: "Hello.<original>! World."},
{name: "before end of sentence", original: "Hello <original>!", expected: "Hello <converted>!"},
{
name: "end of sentence",
original: "End of sentence. <original>",
expected: "End of sentence. <converted>",
},
{
name: "between symbols",
original: "Hello.<original>! World.",
expected: "Hello.<original>! World.",
},
{
name: "before end of sentence",
original: "Hello <original>!",
expected: "Hello <converted>!",
},
];
for (const [shortcut, full_name] of Object.entries(emoji_codes.emoticon_conversions)) {
for (const t of testcases) {
@@ -615,7 +745,8 @@ run_test("translate_emoticons_to_names", () => {
let original = t.original;
let expected = t.expected;
original = original.replace(/(<original>)/g, shortcut);
expected = expected.replace(/(<original>)/g, shortcut)
expected = expected
.replace(/(<original>)/g, shortcut)
.replace(/(<converted>)/g, converted_value);
const result = markdown.translate_emoticons_to_names(original);
assert.equal(result, expected);