![](/img/trans.png)
[英]What are the differences between Elixir GenEvent's handle_call and handle_event?
[英]How to call handle_event from test using Elixir Live View
在 LiveView 中,如何從測試中調用 handle_event。
@impl true
def handle_event("do_thing", _, socket) do
send(self(), :do_the_thing)
{:noreply, assign(socket, :cycler, true)}
end
您不會直接調用它,但可以查看Phoenix.LiveViewTest
提供的render_hook/3
function 。
{:ok, view, _html} = live(conn, "/thermo")
assert view
|> element("#thermo-component")
|> render_hook(:refresh, %{deg: 32}) =~ "The temp is: 32℉"
來源: https://hexdocs.pm/phoenix_live_view/Phoenix.LiveViewTest.html#render_hook/3
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.