View Source Kino.Test (Kino v0.6.0)
Conveniences for testing custom Kino components.
In practice, Kino.JS.Live
kinos communicate with Livebook via
the group leader. During tests, Livebook is out of the equation,
so we need to mimic this side of the communication. To do so, add
the following setup to your test module:
import Kino.Test
setup :configure_livebook_bridge
Link to this section Summary
Functions
Asserts a Kino.JS.Live
kino will broadcast an event within
timeout
.
Asserts the given output is sent to within timeout
.
Asserts a smart cell update will be broadcasted within timeout
.
Connects to a Kino.JS.Live
kino and returns the initial data.
Sends a client event to a Kino.JS.Live
kino.
Starts a smart cell defined by the given module.
Link to this section Functions
Asserts a Kino.JS.Live
kino will broadcast an event within
timeout
.
examples
Examples
assert_broadcast_event(kino, "bump", %{by: 2})
Asserts the given output is sent to within timeout
.
examples
Examples
assert_output({:markdown, "_hey_"})
assert_smart_cell_update(kino, attrs, source, timeout \\ 100)
View Source (macro)Asserts a smart cell update will be broadcasted within timeout
.
Matches against the source and attribute that are reported as part of the update.
examples
Examples
assert_smart_cell_update(kino, %{"variable" => "x", "number" => 10}, "x = 10")
Connects to a Kino.JS.Live
kino and returns the initial data.
If resolve_fun
is given, it runs after sending the connection
request and before awaiting for the reply.
examples
Examples
data = connect(kino)
assert data == %{count: 1}
Sends a client event to a Kino.JS.Live
kino.
examples
Examples
push_event(kino, "bump", %{"by" => 2})
Starts a smart cell defined by the given module.
Returns a Kino.JS.Live
kino for interacting with the cell, as
well as the initial source.
examples
Examples
{kino, source} = start_smart_cell!(Kino.SmartCell.Custom, %{"key" => "value"})