mirrored_repositories/flutter_project_v0.1/test/src
import 'package:dartz/dartz.dart';
import 'package:flutter_project/src/repositories/user_repository.dart';
import 'package:flutter_project/src/use_cases/get_users.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';

import '../entities/entity_helpers.dart';
import 'get_users_test.mocks.dart';

@GenerateMocks([UserRepository])
void main() {
  late GetUsers getUsers;
  late MockUserRepository mockUserRepository;

  setUp(() {
    mockUserRepository = MockUserRepository();
    getUsers = GetUsers(repository: mockUserRepository);
  });

  test('should return list of users', () async {
    when(mockUserRepository.getUsers(
      page: anyNamed('page'),
      limit: anyNamed('limit'),
    )).thenAnswer(
      (_) async => Right(users),
    );

    final result = await getUsers(page: 1, limit: 10);

    expect((result as Right).value, users);

    verify(mockUserRepository.getUsers(page: 1, limit: 10));
  });
}
