Tuix.TestRenderer (tuix v0.1.0)

Copy Markdown View Source

Renders element trees (or whole apps) to buffers and text snapshots without touching the terminal. The Tuix analog of OpenTUI's createTestRenderer.

Example

element =
  box border: :single, width: 12, height: 3 do
    text("hi")
  end

assert Tuix.TestRenderer.render_to_text(element, 20, 5) == """
       ┌──────────┐
       │hi        │
       └──────────┘
       """ |> String.trim_trailing()

Summary

Functions

Renders an element tree or app module at the given size, returning the Tuix.Buffer for structured assertions (cell styles, etc).

Renders to a plain-text snapshot: one string per row joined with newlines, trailing whitespace trimmed.

Functions

render(element_or_module, width, height, opts \\ [])

Renders an element tree or app module at the given size, returning the Tuix.Buffer for structured assertions (cell styles, etc).

render_to_text(element_or_module, width, height, opts \\ [])

@spec render_to_text(
  Tuix.Element.t() | module(),
  pos_integer(),
  pos_integer(),
  keyword()
) :: String.t()

Renders to a plain-text snapshot: one string per row joined with newlines, trailing whitespace trimmed.