@@ -3,8 +3,8 @@ defmodule LiveDebugger.Utils.CallbacksTest do
33
44 alias LiveDebugger.Utils.Callbacks , as: CallbackUtils
55
6- describe "tracing_callbacks /1" do
7- test "returns proper callbacks for LiveView" do
6+ describe "live_view_callbacks /1" do
7+ test "returns proper callbacks for LiveView module " do
88 assert [
99 { LiveDebuggerTest.TestView , :mount , 3 } ,
1010 { LiveDebuggerTest.TestView , :handle_params , 3 } ,
@@ -18,6 +18,35 @@ defmodule LiveDebugger.Utils.CallbacksTest do
1818 ] = CallbackUtils . live_view_callbacks ( LiveDebuggerTest.TestView )
1919 end
2020
21+ test "returns list of callbacks for multiple LiveView modules" do
22+ assert [
23+ { LiveDebuggerTest.TestView1 , :mount , 3 } ,
24+ { LiveDebuggerTest.TestView1 , :handle_params , 3 } ,
25+ { LiveDebuggerTest.TestView1 , :handle_info , 2 } ,
26+ { LiveDebuggerTest.TestView1 , :handle_call , 3 } ,
27+ { LiveDebuggerTest.TestView1 , :handle_cast , 2 } ,
28+ { LiveDebuggerTest.TestView1 , :terminate , 2 } ,
29+ { LiveDebuggerTest.TestView1 , :render , 1 } ,
30+ { LiveDebuggerTest.TestView1 , :handle_event , 3 } ,
31+ { LiveDebuggerTest.TestView1 , :handle_async , 3 } ,
32+ { LiveDebuggerTest.TestView2 , :mount , 3 } ,
33+ { LiveDebuggerTest.TestView2 , :handle_params , 3 } ,
34+ { LiveDebuggerTest.TestView2 , :handle_info , 2 } ,
35+ { LiveDebuggerTest.TestView2 , :handle_call , 3 } ,
36+ { LiveDebuggerTest.TestView2 , :handle_cast , 2 } ,
37+ { LiveDebuggerTest.TestView2 , :terminate , 2 } ,
38+ { LiveDebuggerTest.TestView2 , :render , 1 } ,
39+ { LiveDebuggerTest.TestView2 , :handle_event , 3 } ,
40+ { LiveDebuggerTest.TestView2 , :handle_async , 3 }
41+ ] =
42+ CallbackUtils . live_view_callbacks ( [
43+ LiveDebuggerTest.TestView1 ,
44+ LiveDebuggerTest.TestView2
45+ ] )
46+ end
47+ end
48+
49+ describe "live_component_callbacks/1" do
2150 test "returns proper callbacks for LiveComponent" do
2251 assert [
2352 { LiveDebuggerTest.TestComponent , :mount , 1 } ,
@@ -28,5 +57,42 @@ defmodule LiveDebugger.Utils.CallbacksTest do
2857 { LiveDebuggerTest.TestComponent , :handle_async , 3 }
2958 ] = CallbackUtils . live_component_callbacks ( LiveDebuggerTest.TestComponent )
3059 end
60+
61+ test "returns list of callbacks for multiple LiveComponent modules" do
62+ assert [
63+ { LiveDebuggerTest.TestComponent1 , :mount , 1 } ,
64+ { LiveDebuggerTest.TestComponent1 , :update , 2 } ,
65+ { LiveDebuggerTest.TestComponent1 , :update_many , 1 } ,
66+ { LiveDebuggerTest.TestComponent1 , :render , 1 } ,
67+ { LiveDebuggerTest.TestComponent1 , :handle_event , 3 } ,
68+ { LiveDebuggerTest.TestComponent1 , :handle_async , 3 } ,
69+ { LiveDebuggerTest.TestComponent2 , :mount , 1 } ,
70+ { LiveDebuggerTest.TestComponent2 , :update , 2 } ,
71+ { LiveDebuggerTest.TestComponent2 , :update_many , 1 } ,
72+ { LiveDebuggerTest.TestComponent2 , :render , 1 } ,
73+ { LiveDebuggerTest.TestComponent2 , :handle_event , 3 } ,
74+ { LiveDebuggerTest.TestComponent2 , :handle_async , 3 }
75+ ] =
76+ CallbackUtils . live_component_callbacks ( [
77+ LiveDebuggerTest.TestComponent1 ,
78+ LiveDebuggerTest.TestComponent2
79+ ] )
80+ end
81+ end
82+
83+ test "callbacks_functions/1 returns names of all callbacks" do
84+ assert [
85+ :render ,
86+ :handle_event ,
87+ :handle_async ,
88+ :mount ,
89+ :handle_params ,
90+ :handle_info ,
91+ :handle_call ,
92+ :handle_cast ,
93+ :terminate ,
94+ :update ,
95+ :update_many
96+ ] = CallbackUtils . callbacks_functions ( )
3197 end
3298end
0 commit comments