# `Dstar.Test`
[🔗](https://github.com/ricotrevisan/dstar/blob/v0.3.3/lib/dstar/test.ex#L1)

Assertions for Dstar SSE responses in `Plug.Test` / `Phoenix.ConnTest`
tests. Chunked SSE bodies accumulate in `conn.resp_body` on the test
adapter; these helpers parse them back into events.

    conn = post(conn, "/counter/_event/increment")
    assert_patched_signals(conn, %{count: 1})
    assert_patched_element(conn, "#history")

# `assert_patched_element`

Asserts a `datastar-patch-elements` event targets `target` — either via
an explicit `selector` line or via an `id` attribute in the patched HTML
(pass the target as `"#the-id"` in both cases).
Returns the conn for piping.

# `assert_patched_signals`

Asserts the given signals (a subset) were patched. Keys may be atoms
or strings; values compare against the JSON-decoded patch.
Returns the conn for piping.

# `patched_signals`

Returns the merged map of all signals patched on the conn.

# `sse_events`

Parses the SSE events from a conn (or raw body string) into a list of
`%{type: String.t() | nil, data: [String.t()]}`.
This parser understands Dstar's own SSE output format ("event: " / "data: " with a trailing space, LF line endings) — it is not a general-purpose SSE parser.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
