From 1cf5594f83da623da3eb995faa31ddc5056be65b Mon Sep 17 00:00:00 2001 From: Michael Ruoss Date: Thu, 29 Aug 2024 21:44:56 +0200 Subject: [PATCH 1/2] Add a helper function to test editor source events --- lib/kino/test.ex | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/kino/test.ex b/lib/kino/test.ex index 5ea65e8e..fb0774b8 100644 --- a/lib/kino/test.ex +++ b/lib/kino/test.ex @@ -114,6 +114,18 @@ defmodule Kino.Test do send(kino.pid, {:event, event, payload, %{origin: inspect(self())}}) end + @doc """ + Sends an editor source event to a `Kino.JS.Live` kino. + + ## Examples + + push_editor_source(kino, "source code") + + """ + def push_editor_source(kino, source_code) do + send(kino.pid, {:editor_source, source_code}) + end + @doc """ Connects to a `Kino.JS.Live` kino and returns the initial data. From ea6b9611ba021411223622116ad7a7bf3bebe79f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Thu, 5 Sep 2024 06:04:55 +0200 Subject: [PATCH 2/2] Clarify that the function is smart cell specific --- lib/kino/test.ex | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/kino/test.ex b/lib/kino/test.ex index fb0774b8..c4df05c3 100644 --- a/lib/kino/test.ex +++ b/lib/kino/test.ex @@ -114,18 +114,6 @@ defmodule Kino.Test do send(kino.pid, {:event, event, payload, %{origin: inspect(self())}}) end - @doc """ - Sends an editor source event to a `Kino.JS.Live` kino. - - ## Examples - - push_editor_source(kino, "source code") - - """ - def push_editor_source(kino, source_code) do - send(kino.pid, {:editor_source, source_code}) - end - @doc """ Connects to a `Kino.JS.Live` kino and returns the initial data. @@ -197,4 +185,19 @@ defmodule Kino.Test do unquote(timeout) end end + + @doc """ + Sends a changed smart cell editor source to a `Kino.JS.Live` kino. + + This is going to call `c:Kino.SmartCell.handle_editor_change/2` implementation + in the smart cell module. + + ## Examples + + push_smart_cell_editor_source(kino, "source code") + + """ + def push_smart_cell_editor_source(kino, source) do + send(kino.pid, {:editor_source, source}) + end end