markdown: Assert we handle timestamps sensibly in push notifications.

We could certainly do better with the handling here, but using the raw
string that the user gave us is okayish for now.

Proper formatting of timestamps requires handling locales and timezones
of the receiver as well which is a larger project.
This commit is contained in:
Rohitt Vashishtha 2020-07-15 02:32:32 +05:30 committed by Tim Abbott
parent 78c48935ca
commit 1a9a478e5d
1 changed files with 13 additions and 7 deletions

View File

@ -726,35 +726,41 @@
"name": "timestamp_backend_markdown_only",
"input": "<time:Jun 5th 2017, 10:30PM>",
"expected_output": "<p><time datetime=\"2017-06-05T22:30:00Z\">Jun 5th 2017, 10:30PM</time></p>",
"marked_expected_output": "<p><span>Jun 5th 2017, 10:30PM</span></p>"
"marked_expected_output": "<p><span>Jun 5th 2017, 10:30PM</span></p>",
"text_content": "Jun 5th 2017, 10:30PM"
},
{
"name": "timestamp_backend_markdown_and_marked",
"input": "<time:31 Dec 2017>",
"expected_output": "<p><time datetime=\"2017-12-31T00:00:00Z\">31 Dec 2017</time></p>"
"expected_output": "<p><time datetime=\"2017-12-31T00:00:00Z\">31 Dec 2017</time></p>",
"text_content": "31 Dec 2017"
},
{
"name": "timestamp_invalid_input",
"input": "<time:<alert(1)>>",
"expected_output": "<p><span class=\"timestamp-error\">Invalid time format: &lt;alert(1)</span>&gt;</p>",
"marked_expected_output": "<p><span>&lt;alert(1)</span>&gt;</p>"
"marked_expected_output": "<p><span>&lt;alert(1)</span>&gt;</p>",
"text_content": "Invalid time format: <alert(1)>"
},
{
"name": "timestamp_timezone",
"input": "<time:31 Dec 2017 5:30 am IST>",
"expected_output": "<p><time datetime=\"2017-12-31T00:00:00Z\">31 Dec 2017 5:30 am IST</time></p>",
"marked_expected_output": "<p><span>31 Dec 2017 5:30 am IST</span></p>"
"marked_expected_output": "<p><span>31 Dec 2017 5:30 am IST</span></p>",
"text_content": "31 Dec 2017 5:30 am IST"
},
{
"name": "timestamp_incorrect",
"input": "<time:**hello world**>",
"expected_output": "<p><span class=\"timestamp-error\">Invalid time format: **hello world**</span></p>",
"marked_expected_output": "<p><span>**hello world**</span></p>"
"marked_expected_output": "<p><span>**hello world**</span></p>",
"text_content": "Invalid time format: **hello world**"
},
{
"name": "timestamp_unix",
"input": "<time:1496701800>",
"expected_output": "<p><time datetime=\"2017-06-05T22:30:00Z\">1496701800</time></p>"
"input": "Let's meet at <time:1496701800>.",
"expected_output": "<p>Let's meet at <time datetime=\"2017-06-05T22:30:00Z\">1496701800</time>.</p>",
"text_content": "Let's meet at 1496701800."
},
{
"name": "tex_inline",