# retoor <retoor@molodetz.nl>

from devplacepy.services.jobs.isslop.badge import badge_html, badge_markdown, render_badge


def test_render_badge_with_grade():
    svg = render_badge(87.5, "A", "https://devplace.example/tools/isslop/abc/report")
    assert svg.startswith("<svg")
    assert "88%" in svg or "87%" in svg
    assert "authenticity" in svg
    assert "https://devplace.example/tools/isslop/abc/report" in svg


def test_render_badge_pending():
    svg = render_badge(None, None, "https://devplace.example/tools/isslop/abc/report")
    assert "analyzing" in svg


def test_render_badge_escapes_url():
    svg = render_badge(50.0, "C", 'https://x.example/"><script>')
    assert "<script>" not in svg


def test_badge_snippets():
    markdown = badge_markdown("https://x/badge.svg", "https://x/report")
    assert markdown == "[![authenticity human score](https://x/badge.svg)](https://x/report)"
    html = badge_html("https://x/badge.svg", "https://x/report")
    assert '<img src="https://x/badge.svg"' in html
