def test_optional_list():
    """Test that the foreach component works with optional lists."""
    Foreach.create(
        ForEachState.optional_list,
        lambda color: text(color),
    )

    Foreach.create(
        ForEachState.optional_list_value,
        lambda color: text(color),
    )

    Foreach.create(
        ForEachState.optional_dict,
        lambda color: text(color[0], color[1]),
    )

    Foreach.create(
        ForEachState.optional_dict_value,
        lambda color: text(color[0], color[1]),
    )
Test that the foreach component works with optional lists.
tests/units/components/core/test_foreach.py