Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
renatho committed Nov 11, 2024
1 parent fbef999 commit f96d7eb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions projects/plugins/wpcomsh/tests/test-wpcomsh.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public function test_wpcomsh_make_content_clickable() {
$div_skip = '<div class="skip-make-clickable test">https://wp.com</div>';
$custom_element = '<custom-element>https://wp.com</custom-element>';
$custom_element_starts_with_pre = '<presto-player>https://wp.com</presto-player>';
$link_inside_tag_inside_attr = '
<li data-test="<a href=\&quot;https://wp.com\&quot;&gt;Link</a&gt;"></li>';

$original_content = '' .
$script .
Expand All @@ -40,7 +42,8 @@ public function test_wpcomsh_make_content_clickable() {
$textarea .
$div_skip .
$custom_element .
$custom_element_starts_with_pre;
$custom_element_starts_with_pre .
$link_inside_tag_inside_attr;

$expected_output = '' .
'<script>https://wp.com</script>' .
Expand All @@ -52,7 +55,9 @@ public function test_wpcomsh_make_content_clickable() {
'<textarea>https://wp.com</textarea>' .
'<div class="skip-make-clickable test">https://wp.com</div>' .
'<custom-element><a href="https://wp.com" rel="nofollow">https://wp.com</a></custom-element>' . // Made clickable
'<presto-player><a href="https://wp.com" rel="nofollow">https://wp.com</a></presto-player>'; // Made clickable even if it starts with `<pre`
'<presto-player><a href="https://wp.com" rel="nofollow">https://wp.com</a></presto-player>' . // Made clickable even if it starts with `<pre`
'' . // Empty line needed for the following check.
'<li data-test="<a href=\&quot;https://wp.com\&quot;&gt;Link</a&gt;"></li>'; // Don't make clickable if it's inside a tag inside an attribute.

$this->assertEquals( $expected_output, wpcomsh_make_content_clickable( $original_content ) );
}
Expand Down

0 comments on commit f96d7eb

Please sign in to comment.