summaryrefslogtreecommitdiffstats
path: root/tests/core/test_html.py
blob: d4c74dcbcb2a62d8e714adf7f5924c38a21c184a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from core.html import html_to_plaintext, sanitize_post


def test_html_to_plaintext():

    assert html_to_plaintext("<p>Hi!</p>") == "Hi!"
    assert html_to_plaintext("<p>Hi!<br>There</p>") == "Hi!\nThere"
    assert (
        html_to_plaintext("<p>Hi!</p>\n\n<p>How are you?</p>") == "Hi!\n\nHow are you?"
    )

    assert (
        html_to_plaintext("<p>Hi!</p>\n\n<p>How are<br> you?</p><p>today</p>")
        == "Hi!\n\nHow are\n you?\n\ntoday"
    )


def test_sanitize_post():

    assert sanitize_post("<p>Hello!</p>") == "<p>Hello!</p>"
    assert sanitize_post("<p>It&#39;s great</p>") == "<p>It&#39;s great</p>"