-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmodule_discovery_test.exs
52 lines (43 loc) · 1.24 KB
/
module_discovery_test.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
defmodule LiveDebugger.Services.ModuleDiscoveryTest do
use ExUnit.Case, async: true
alias LiveDebugger.Services.ModuleDiscovery
describe "find_live_modules/0" do
test "finds LiveViews and LiveComponents correctly" do
Module.create(
LiveDebuggerTest.TestView,
live_view_contents(),
Macro.Env.location(__ENV__)
)
Module.create(
LiveDebuggerTest.TestComponent,
live_component_contents(),
Macro.Env.location(__ENV__)
)
Module.create(
LiveDebuggerTest.OtherModule,
other_contents(),
Macro.Env.location(__ENV__)
)
%{live_views: live_views, live_components: live_components} =
ModuleDiscovery.find_live_modules()
assert Enum.any?(live_views, &(&1 == LiveDebuggerTest.TestView))
assert Enum.any?(live_components, &(&1 == LiveDebuggerTest.TestComponent))
refute Enum.any?(live_views, &(&1 == LiveDebuggerTest.OtherModule))
end
end
defp live_view_contents() do
quote do
@behaviour Phoenix.LiveView
end
end
defp live_component_contents() do
quote do
@behaviour Phoenix.LiveComponent
end
end
defp other_contents() do
quote do
@behaviour Other.Behaviour
end
end
end