Raxol.Test.Integration.Assertions (Raxol v0.4.0)

View Source

Provides custom assertions for integration testing of Raxol components.

This module includes assertions for:

  • Component interaction verification
  • Event propagation validation
  • State synchronization checking
  • Command routing verification
  • Component lifecycle testing

Summary

Functions

Asserts that a child component received an event from its parent.

Asserts that commands are properly routed between components.

Asserts that error boundaries contain component failures.

Asserts that events are properly propagated through the component hierarchy.

Asserts that components are properly connected in a hierarchy.

Asserts that a component properly handles mounting and unmounting.

Asserts that a parent component was updated in response to a child event.

Asserts that component state is synchronized after interactions.

Asserts that a component handles system events without corruption.

Functions

assert_child_received(child, expected_event)

Asserts that a child component received an event from its parent.

Example

assert_child_received child, :parent_clicked

assert_command_routing(source, target, command)

Asserts that commands are properly routed between components.

Example

assert_command_routing source, target, command

assert_error_contained(parent, child, error_fn)

Asserts that error boundaries contain component failures.

Example

assert_error_contained parent, child, fn ->
  simulate_user_action(child, :trigger_error)
end

assert_event_propagation(components, event, verification_fn)

Asserts that events are properly propagated through the component hierarchy.

Example

assert_event_propagation [parent, child1, child2], event, fn components ->
  # Verify each component's response
end

assert_hierarchy_valid(parent, children)

Asserts that components are properly connected in a hierarchy.

Example

assert_hierarchy_valid parent, [child1, child2]

assert_lifecycle_handled(component, lifecycle_fn)

Asserts that a component properly handles mounting and unmounting.

Example

assert_lifecycle_handled component, fn comp ->
  mount_component(comp)
  # Test mounted state
  unmount_component(comp)
  # Test unmounted state
end

assert_parent_updated(parent, expected_update)

Asserts that a parent component was updated in response to a child event.

Example

assert_parent_updated parent, :child_responded

assert_state_synchronized(components, state_check)

Asserts that component state is synchronized after interactions.

Example

assert_state_synchronized [comp1, comp2], fn states ->
  Enum.all?(states, & &1.counter == 0)
end

assert_system_events_handled(component, events)

Asserts that a component handles system events without corruption.

Example

assert_system_events_handled component, [:resize, :focus, :blur]