defmodule MvWeb.Helpers.JoinDescriptionRendererTest do @moduledoc """ Tests for the join-description renderer that auto-links raw URLs and Markdown links while escaping all other content. """ use ExUnit.Case, async: true use ExUnitProperties alias MvWeb.Helpers.JoinDescriptionRenderer defp html(value) do value |> JoinDescriptionRenderer.render() |> Phoenix.HTML.safe_to_string() end describe "render/1" do test "converts a raw URL to an anchor tag" do result = html("Akzeptiere https://example.com/dsgvo") assert result =~ ~s(" assert result =~ "Akzeptiere " end test "converts Markdown [text](url) to an anchor tag with the link text" do result = html("[Datenschutzerklärung](https://example.com/dsgvo)") assert result =~ ~s(Datenschutzerklärung" end test "returns an empty safe string for nil input" do assert JoinDescriptionRenderer.render(nil) == {:safe, ""} end test "escapes arbitrary HTML in non-link text" do result = html("") refute result =~ "