"""Tests for Strip node."""

import pytest

from fw_nodes_core.nodes.strip import StripNode


@pytest.mark.asyncio
async def test_strip_whitespace(node_execution_context):
    """Test stripping leading and trailing whitespace."""
    node = StripNode()

    result = await node.execute({"text": "  hello world  "}, node_execution_context)

    assert result.text == "hello world"


@pytest.mark.asyncio
async def test_strip_tabs_and_newlines(node_execution_context):
    """Test stripping tabs and newlines."""
    node = StripNode()

    result = await node.execute({"text": "\n\thello\t\n"}, node_execution_context)

    assert result.text == "hello"


@pytest.mark.asyncio
async def test_strip_unicode_whitespace(node_execution_context):
    """Test stripping unicode whitespace characters."""
    node = StripNode()

    # \u00a0 = non-breaking space, \u2003 = em space
    result = await node.execute({"text": "\u00a0hello\u2003"}, node_execution_context)

    assert result.text == "hello"


@pytest.mark.asyncio
async def test_strip_empty_string(node_execution_context):
    """Test stripping empty string returns empty string."""
    node = StripNode()

    result = await node.execute({"text": "   "}, node_execution_context)

    assert result.text == ""


@pytest.mark.asyncio
async def test_strip_already_clean(node_execution_context):
    """Test that clean strings pass through unchanged."""
    node = StripNode()

    result = await node.execute({"text": "hello"}, node_execution_context)

    assert result.text == "hello"
