Test helpers for Raxol plugins.
Provides utilities for exercising plugin callbacks in isolation without starting the full plugin manager infrastructure.
Usage
use ExUnit.Case
import Raxol.Plugin.Testing
test "handles events" do
{:ok, state} = setup_plugin(MyPlugin, %{key: "value"})
assert_handles_event(MyPlugin, :some_event, state)
end
Summary
Functions
Asserts that a plugin halts a given event.
Asserts that a plugin handles a command successfully.
Asserts that a plugin handles an event without halting.
Initializes a plugin module with the given config and returns its state.
Runs a plugin through its full lifecycle: init -> enable -> disable -> terminate.
Functions
Asserts that a plugin halts a given event.
Calls module.filter_event(event, state) and asserts the result is :halt.
Examples
assert_halts_event(MyPlugin, :blocked_event, state)
Asserts that a plugin handles a command successfully.
Calls module.handle_command(command, args, state) and asserts the
result matches {:ok, new_state, result}. Returns {new_state, result}.
Examples
{new_state, result} = assert_handles_command(MyPlugin, :do_thing, [1, 2], state)
Asserts that a plugin handles an event without halting.
Calls module.filter_event(event, state) and asserts the result
matches {:ok, _}. Returns the (possibly modified) event.
Examples
event = assert_handles_event(MyPlugin, :click, state)
Initializes a plugin module with the given config and returns its state.
Calls module.init(config) and asserts it returns {:ok, state}.
Examples
{:ok, state} = setup_plugin(MyPlugin, %{})
Runs a plugin through its full lifecycle: init -> enable -> disable -> terminate.
Asserts each step succeeds. Returns a list of {callback, result} tuples
for inspection.
Examples
steps = simulate_lifecycle(MyPlugin, %{option: true})
assert length(steps) == 4