diff --git a/test/utils/callbacks_test.exs b/test/utils/callbacks_test.exs index b46e3e76c..360853f16 100644 --- a/test/utils/callbacks_test.exs +++ b/test/utils/callbacks_test.exs @@ -3,8 +3,8 @@ defmodule LiveDebugger.Utils.CallbacksTest do alias LiveDebugger.Utils.Callbacks, as: CallbackUtils - describe "tracing_callbacks/1" do - test "returns proper callbacks for LiveView" do + describe "live_view_callbacks/1" do + test "returns proper callbacks for LiveView module" do assert [ {LiveDebuggerTest.TestView, :mount, 3}, {LiveDebuggerTest.TestView, :handle_params, 3}, @@ -18,6 +18,35 @@ defmodule LiveDebugger.Utils.CallbacksTest do ] = CallbackUtils.live_view_callbacks(LiveDebuggerTest.TestView) end + test "returns list of callbacks for multiple LiveView modules" do + assert [ + {LiveDebuggerTest.TestView1, :mount, 3}, + {LiveDebuggerTest.TestView1, :handle_params, 3}, + {LiveDebuggerTest.TestView1, :handle_info, 2}, + {LiveDebuggerTest.TestView1, :handle_call, 3}, + {LiveDebuggerTest.TestView1, :handle_cast, 2}, + {LiveDebuggerTest.TestView1, :terminate, 2}, + {LiveDebuggerTest.TestView1, :render, 1}, + {LiveDebuggerTest.TestView1, :handle_event, 3}, + {LiveDebuggerTest.TestView1, :handle_async, 3}, + {LiveDebuggerTest.TestView2, :mount, 3}, + {LiveDebuggerTest.TestView2, :handle_params, 3}, + {LiveDebuggerTest.TestView2, :handle_info, 2}, + {LiveDebuggerTest.TestView2, :handle_call, 3}, + {LiveDebuggerTest.TestView2, :handle_cast, 2}, + {LiveDebuggerTest.TestView2, :terminate, 2}, + {LiveDebuggerTest.TestView2, :render, 1}, + {LiveDebuggerTest.TestView2, :handle_event, 3}, + {LiveDebuggerTest.TestView2, :handle_async, 3} + ] = + CallbackUtils.live_view_callbacks([ + LiveDebuggerTest.TestView1, + LiveDebuggerTest.TestView2 + ]) + end + end + + describe "live_component_callbacks/1" do test "returns proper callbacks for LiveComponent" do assert [ {LiveDebuggerTest.TestComponent, :mount, 1}, @@ -28,5 +57,42 @@ defmodule LiveDebugger.Utils.CallbacksTest do {LiveDebuggerTest.TestComponent, :handle_async, 3} ] = CallbackUtils.live_component_callbacks(LiveDebuggerTest.TestComponent) end + + test "returns list of callbacks for multiple LiveComponent modules" do + assert [ + {LiveDebuggerTest.TestComponent1, :mount, 1}, + {LiveDebuggerTest.TestComponent1, :update, 2}, + {LiveDebuggerTest.TestComponent1, :update_many, 1}, + {LiveDebuggerTest.TestComponent1, :render, 1}, + {LiveDebuggerTest.TestComponent1, :handle_event, 3}, + {LiveDebuggerTest.TestComponent1, :handle_async, 3}, + {LiveDebuggerTest.TestComponent2, :mount, 1}, + {LiveDebuggerTest.TestComponent2, :update, 2}, + {LiveDebuggerTest.TestComponent2, :update_many, 1}, + {LiveDebuggerTest.TestComponent2, :render, 1}, + {LiveDebuggerTest.TestComponent2, :handle_event, 3}, + {LiveDebuggerTest.TestComponent2, :handle_async, 3} + ] = + CallbackUtils.live_component_callbacks([ + LiveDebuggerTest.TestComponent1, + LiveDebuggerTest.TestComponent2 + ]) + end + end + + test "callbacks_functions/1 returns names of all callbacks" do + assert [ + :render, + :handle_event, + :handle_async, + :mount, + :handle_params, + :handle_info, + :handle_call, + :handle_cast, + :terminate, + :update, + :update_many + ] = CallbackUtils.callbacks_functions() end end