import 'package:afterwork/domain/entities/user.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  group('User Entity', () {
    const tUserId = '123';
    const tUserLastName = 'Doe';
    const tUserFirstName = 'John';
    const tEmail = 'john.doe@example.com';
    const tMotDePasse = 'hashedPassword123';
    const tProfileImageUrl = 'https://example.com/profile.jpg';
    const tEventsCount = 5;
    const tFriendsCount = 10;
    const tPostsCount = 15;
    const tVisitedPlacesCount = 20;

    test('should create a User instance with all required fields', () {
      // Act
      const user = User(
        userId: tUserId,
        userLastName: tUserLastName,
        userFirstName: tUserFirstName,
        email: tEmail,
        motDePasse: tMotDePasse,
        profileImageUrl: tProfileImageUrl,
      );

      // Assert
      expect(user.userId, tUserId);
      expect(user.userLastName, tUserLastName);
      expect(user.userFirstName, tUserFirstName);
      expect(user.email, tEmail);
      expect(user.motDePasse, tMotDePasse);
      expect(user.profileImageUrl, tProfileImageUrl);
      expect(user.eventsCount, 0); // Default value
      expect(user.friendsCount, 0); // Default value
      expect(user.postsCount, 0); // Default value
      expect(user.visitedPlacesCount, 0); // Default value
    });

    test('should create a User instance with optional counts', () {
      // Act
      const user = User(
        userId: tUserId,
        userLastName: tUserLastName,
        userFirstName: tUserFirstName,
        email: tEmail,
        motDePasse: tMotDePasse,
        profileImageUrl: tProfileImageUrl,
        eventsCount: tEventsCount,
        friendsCount: tFriendsCount,
        postsCount: tPostsCount,
        visitedPlacesCount: tVisitedPlacesCount,
      );

      // Assert
      expect(user.eventsCount, tEventsCount);
      expect(user.friendsCount, tFriendsCount);
      expect(user.postsCount, tPostsCount);
      expect(user.visitedPlacesCount, tVisitedPlacesCount);
    });

    test('should support value equality using Equatable', () {
      // Arrange
      const user1 = User(
        userId: tUserId,
        userLastName: tUserLastName,
        userFirstName: tUserFirstName,
        email: tEmail,
        motDePasse: tMotDePasse,
        profileImageUrl: tProfileImageUrl,
      );

      const user2 = User(
        userId: tUserId,
        userLastName: tUserLastName,
        userFirstName: tUserFirstName,
        email: tEmail,
        motDePasse: tMotDePasse,
        profileImageUrl: tProfileImageUrl,
      );

      // Assert
      expect(user1, equals(user2));
      expect(user1.hashCode, equals(user2.hashCode));
    });

    test('should not be equal when any field is different', () {
      // Arrange
      const user1 = User(
        userId: tUserId,
        userLastName: tUserLastName,
        userFirstName: tUserFirstName,
        email: tEmail,
        motDePasse: tMotDePasse,
        profileImageUrl: tProfileImageUrl,
      );

      const user2 = User(
        userId: 'different-id',
        userLastName: tUserLastName,
        userFirstName: tUserFirstName,
        email: tEmail,
        motDePasse: tMotDePasse,
        profileImageUrl: tProfileImageUrl,
      );

      // Assert
      expect(user1, isNot(equals(user2)));
    });

    test('props should contain all fields for equality comparison', () {
      // Arrange
      const user = User(
        userId: tUserId,
        userLastName: tUserLastName,
        userFirstName: tUserFirstName,
        email: tEmail,
        motDePasse: tMotDePasse,
        profileImageUrl: tProfileImageUrl,
        eventsCount: tEventsCount,
        friendsCount: tFriendsCount,
        postsCount: tPostsCount,
        visitedPlacesCount: tVisitedPlacesCount,
      );

      // Act
      final props = user.props;

      // Assert
      expect(props.length, 10);
      expect(
        props,
        containsAll([
          tUserId,
          tUserLastName,
          tUserFirstName,
          tEmail,
          tMotDePasse,
          tProfileImageUrl,
          tEventsCount,
          tFriendsCount,
          tPostsCount,
          tVisitedPlacesCount,
        ]),
      );
    });
  });
}

