X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/25aea657e280204f1083a72279a4fb5bd5b521e6..37edcb113a5dcbdc79e6e90b53f6f643c568c437:/test/lib/rich_text_test.rb?ds=inline
diff --git a/test/lib/rich_text_test.rb b/test/lib/rich_text_test.rb
index 8c1205317..e601c36fc 100644
--- a/test/lib/rich_text_test.rb
+++ b/test/lib/rich_text_test.rb
@@ -275,11 +275,41 @@ class RichTextTest < ActiveSupport::TestCase
assert_equal "https://example.com/image1.jpg", r.image
end
+ def test_markdown_image_with_empty_src
+ r = RichText.new("markdown", "![invalid]()")
+ assert_nil r.image
+ end
+
+ def test_markdown_skip_image_with_empty_src
+ r = RichText.new("markdown", "![invalid]() ![valid](https://example.com/valid.gif)")
+ assert_equal "https://example.com/valid.gif", r.image
+ end
+
def test_markdown_html_image
r = RichText.new("markdown", "")
assert_equal "https://example.com/img_element.png", r.image
end
+ def test_markdown_html_image_with_empty_src
+ r = RichText.new("markdown", "")
+ assert_nil r.image
+ end
+
+ def test_markdown_skip_html_image_with_empty_src
+ r = RichText.new("markdown", " ")
+ assert_equal "https://example.com/next_img_element.png", r.image
+ end
+
+ def test_markdown_html_image_without_src
+ r = RichText.new("markdown", "")
+ assert_nil r.image
+ end
+
+ def test_markdown_skip_html_image_without_src
+ r = RichText.new("markdown", " ")
+ assert_equal "https://example.com/next_img_element.png", r.image
+ end
+
private
def assert_html(richtext, &block)