import json import subprocess from pathlib import Path def test_calendar_location_escapes_markup_surrounding_links(): source = (Path(__file__).resolve().parents[1] / "static/js/calendar.js").read_text() function = source[source.index("function _locHTML("):source.index("// ── Open / Close", source.index("function _locHTML("))] script = r''' const _e = value => String(value).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); ''' + function + r''' const location = ' https://example.test/meeting '; console.log(JSON.stringify(_locHTML(location))); ''' result = subprocess.run(["node", "--input-type=module", "-e", script], capture_output=True, text=True, check=True) html = json.loads(result.stdout) assert "