Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismccord committed Aug 12, 2023
1 parent 353e834 commit cb35f0f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/phoenix_live_view/test/live_view_test.ex
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,16 @@ defmodule Phoenix.LiveViewTest do
end

@doc """
TODO
Awaits all current `assign_async` and `start_async` for a given LiveView or element.
It renders the LiveView or Element once complete and returns the result.
By default, the timeout is 100ms, but a custom time may be passed to override.
## Examples
{:ok, lv, html} = live(conn, "/path")
assert html =~ "loading data..."
assert render_async(lv) =~ "data loaded!"
"""
def render_async(view_or_element, timeout \\ 100) do
pids =
Expand All @@ -942,7 +951,7 @@ defmodule Phoenix.LiveViewTest do
end)
end)

case Task.yield(task, timeout) || Task.ignore(task) do
case Task.yield(task, timeout) || Task.shutdown(task) do
{:ok, _} -> :ok
nil -> raise RuntimeError, "expected async processes to finish within #{timeout}ms"
end
Expand Down

0 comments on commit cb35f0f

Please sign in to comment.