import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:garden_planner/widgets/content_widgets/dashboard_widgets/space/plant_row_horizontal_space.dart';

void main() {
  testWidgets('PlantRowHorizontalSpace displays planting positions',
      (WidgetTester tester) async {
    // Arrange
    final List<double> plantingPositions = [1.0, 2.5, 3.0];

    // Act
    await tester.pumpWidget(
      MaterialApp(
        home: Scaffold(
          body: PlantRowHorizontalSpace(
            plantingPositions: plantingPositions,
          ),
        ),
      ),
    );

    // Assert
    // 4 because of 3 positions and 1 plain starting
    expect(find.byType(Container), findsNWidgets(4));
  });

  testWidgets('PlantRowHorizontalSpace displays correct item text',
      (WidgetTester tester) async {
    // Arrange
    final List<double> plantingPositions = [1.5, 2.5, 3.5];

    // Act
    await tester.pumpWidget(
      MaterialApp(
        home: Scaffold(
          body: PlantRowHorizontalSpace(
            plantingPositions: plantingPositions,
          ),
        ),
      ),
    );

    // Assert
    // Skip the first position because it's a placeholder
    for (double position in plantingPositions) {
      final itemTextFinder = find.text('${position.toStringAsFixed(2)} m');
      expect(itemTextFinder, findsOneWidget);
    }
  });
}
