"""Unit tests for accessibility mode node."""

import pytest


def test_accessibility_node_init():
    """Test accessibility mode node initialization."""
    import rclpy

    rclpy.init(allow_reuse=True)
    from saltybot_accessibility_mode.accessibility_mode_node import AccessibilityModeNode

    node = AccessibilityModeNode()
    assert node.enabled is True
    assert node.keyboard_enabled is True
    assert len(node.display_history) == 0
    node.destroy_node()


def test_keyboard_buffer():
    """Test keyboard buffer management."""
    import rclpy

    rclpy.init(allow_reuse=True)
    from saltybot_accessibility_mode.accessibility_mode_node import AccessibilityModeNode

    node = AccessibilityModeNode()
    node.keyboard_buffer = "HELLO"
    assert node.keyboard_buffer == "HELLO"
    node.destroy_node()


def test_history_limit():
    """Test display history limit."""
    import rclpy

    rclpy.init(allow_reuse=True)
    from saltybot_accessibility_mode.accessibility_mode_node import AccessibilityModeNode

    node = AccessibilityModeNode()
    # Add more entries than max_history
    for i in range(15):
        node.display_history.append({"type": "test", "text": f"Entry {i}"})

    assert len(node.display_history) <= node.max_history
    node.destroy_node()


if __name__ == "__main__":
    pytest.main([__file__, "-v"])
