def test_event_window_alert():
    """Test the event window alert function."""
    spec = event.window_alert("message")
    assert isinstance(spec, EventSpec)
    assert spec.handler.fn.__qualname__ == "_call_function"
    assert spec.args[0][0].equals(Var(_js_expr="function"))
    assert spec.args[0][1].equals(
        Var('(() => (window["alert"]("message")))', _var_type=Callable)
    )
    assert (
        format.format_event(spec)
        == 'Event("_call_function", {function:(() => (window["alert"]("message"))),callback:null})'
    )
    spec = event.window_alert(Var(_js_expr="message"))
    assert (
        format.format_event(spec)
        == 'Event("_call_function", {function:(() => (window["alert"](message))),callback:null})'
    )
    spec2 = event.window_alert(Var(_js_expr="message2")).add_args(Var("throwaway"))
    assert (
        format.format_event(spec2)
        == 'Event("_call_function", {function:(() => (window["alert"](message2))),callback:null})'
    )
Test the event window alert function.
tests/units/test_event.py