Raxol.Test.Unit.Assertions (Raxol v0.3.0)
View SourceProvides custom assertions for testing Raxol components.
This module includes assertions for:
- Component state validation
- Event handling verification
- Command emission checking
- Render output validation
- Layout verification
- Style application testing
Summary
Functions
Asserts that a component emitted specific commands in sequence.
Asserts that a component properly handles an error condition.
Asserts that a component's layout matches the expected constraints.
Asserts that a component's rendered output matches the expected output.
Asserts that a component's state history includes specific changes.
Asserts that a style is properly applied to a component.
Asserts that a component has specific subscriptions active.
Functions
Asserts that a component emitted specific commands in sequence.
Example
assert_command_sequence component, [
{:update, :text},
{:notify, :changed},
{:submit}
]
Asserts that a component properly handles an error condition.
Example
assert_handles_error component, fn ->
simulate_event(component, invalid_event())
end
Asserts that a component's layout matches the expected constraints.
Example
assert_layout component, %{
width: 10,
height: 5,
x: 0,
y: 0
}
Asserts that a component's rendered output matches the expected output.
Example
assert_rendered component, fn output ->
assert output.type == :text
assert output.content == "Hello, World!"
end
Asserts that a component's state history includes specific changes.
Example
assert_state_history component, [
%{text: ""},
%{text: "Hello"},
%{text: "Hello, World!"}
]
Asserts that a style is properly applied to a component.
Example
assert_style component, %{
color: :blue,
background: :white,
bold: true
}
Asserts that a component has specific subscriptions active.
Example
assert_subscribed component, [:keyboard, :mouse]