"""Tests for the Jinja ↔ s-expression bridge.""" import asyncio from shared.sx.jinja_bridge import ( sx, sx_async, register_components, get_component_env, _COMPONENT_ENV, ) # --------------------------------------------------------------------------- # Helpers # --------------------------------------------------------------------------- def run(coro): return asyncio.run(coro) def setup_function(): """Clear component env before each test.""" _COMPONENT_ENV.clear() # --------------------------------------------------------------------------- # sx() — synchronous rendering # --------------------------------------------------------------------------- class TestSx: def test_simple_html(self): assert sx('(div "Hello")') == "
Alice
" def test_multiple_kwargs(self): html = sx('(a :href url title)', url="/about", title="About") assert html == 'About' def test_escaping(self): html = sx('(p text)', text="") assert "<script>" in html assert "