|
13 | 13 | has_return_outside_function, |
14 | 14 | is_script_already_function, |
15 | 15 | validate_browser_paths, |
| 16 | + extract_text_from_html, |
16 | 17 | ) |
17 | 18 |
|
18 | 19 |
|
@@ -401,3 +402,26 @@ def test_has_return_outside_function_arrow_function(self): |
401 | 402 | ''' |
402 | 403 | assert has_return_outside_function(script) is False |
403 | 404 |
|
| 405 | + def test_extract_text_without_strip_without_separator(self): |
| 406 | + html = ('<div>Hello <span> world </span><script>alert(1)</script><style>body { color: red; }</style>' |
| 407 | + '<template>hidden</template></div>') |
| 408 | + result = extract_text_from_html(html) |
| 409 | + assert result == 'Hello world ' |
| 410 | + |
| 411 | + def test_extract_text_with_strip_without_separator(self): |
| 412 | + html = ('<div>Hello <span> world </span><script>alert(1)</script><style>body { color: red; }</style>' |
| 413 | + '<template>hidden</template></div>') |
| 414 | + result = extract_text_from_html(html, strip=True) |
| 415 | + assert result == 'Helloworld' |
| 416 | + |
| 417 | + def test_extract_text_without_strip_with_separator(self): |
| 418 | + html = ('<div>Hello <span> world </span><script>alert(1)</script><style>body { color: red; }</style>' |
| 419 | + '<template>hidden</template></div>') |
| 420 | + result = extract_text_from_html(html, separator="/") |
| 421 | + assert result == 'Hello / world ' |
| 422 | + |
| 423 | + def test_extract_text_with_strip_with_separator(self): |
| 424 | + html = ('<div>Hello <span> world </span><script>alert(1)</script><style>body { color: red; }</style>' |
| 425 | + '<template>hidden</template></div>') |
| 426 | + result = extract_text_from_html(html, strip=True, separator="/") |
| 427 | + assert result == 'Hello/world' |
0 commit comments