Raxol.Test.ButtonHelpers (Raxol v0.2.0)

View Source

Helper functions for testing button components.

This module provides specialized functions for:

  • Button component setup
  • Interaction testing
  • Visual verification
  • Style testing

Summary

Functions

Asserts that a child component received an event from parent.

Verifies that error handling works properly between components.

Asserts that a parent component was updated after a child event.

Verifies that state is synchronized between components.

Verifies that a component properly handles system events.

Captures the rendered output of a component.

Sets up a component hierarchy for testing parent-child interactions.

Sets up an isolated component for button testing.

Sets up a component for visual testing.

Simulates a user event on the button.

Simulates a user action on the button component.

Functions

assert_aligned(component, alignment_type)

assert_child_received(child, event_name)

Asserts that a child component received an event from parent.

assert_error_contained(parent, child, error_fn)

Verifies that error handling works properly between components.

assert_matches_snapshot(component, snapshot_name)

assert_parent_updated(parent, update_type)

Asserts that a parent component was updated after a child event.

assert_renders_with(component, expected_text)

assert_responsive(component, sizes)

assert_state_synchronized(components, validation_fn)

Verifies that state is synchronized between components.

assert_styled_with(component, expected_styles)

assert_system_events_handled(component, events)

Verifies that a component properly handles system events.

assert_theme_consistent(component, themes)

capture_render(component)

Captures the rendered output of a component.

matches_box_edges(output)

matches_color(output, color, text)

matches_component(output, component_type, expected_content)

matches_layout(output, layout_type, opts \\ [])

matches_style(output, style, text)

setup_component_hierarchy(parent_module, child_module)

Sets up a component hierarchy for testing parent-child interactions.

Parameters:

  • parent_module: The parent component module
  • child_module: The child/button component module

Returns:

  • {:ok, parent, child} with initialized components

setup_isolated_component(module, props \\ %{})

Sets up an isolated component for button testing.

Parameters:

  • module: The button component module
  • props: Optional properties to initialize the button with

Returns:

  • {:ok, button} with the initialized button component

setup_visual_component(module, props \\ %{})

Sets up a component for visual testing.

simulate_event(button, event)

Simulates a user event on the button.

Parameters:

  • button: The button component
  • event: The event to simulate (e.g., click, focus)

Returns:

  • Updated button and any commands emitted

simulate_user_action(button, action)

Simulates a user action on the button component.

Parameters:

  • button: The button component
  • action: The action to simulate