import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/model/customer.dart';
import 'package:aitrainer_app/service/customer_service.dart';
import 'package:flutter_test/flutter_test.dart';

//import 'package:mockito/mockito.dart';

// Create a MockClient using the Mock class provided by the Mockito package.
// Create new instances of this class in each test.
/* class MockClient extends Mock implements CustomerApi {
  Future<List<Customer>> getTrainees(int trainerId) async {
    if (trainerId == 62) {
      List<Customer> list = List<Customer>();
      Customer customer1 = Customer(firstname: "Zalán", name: "Boss");
      Customer customer2 = Customer(firstname: "Zétény", name: "Boss");
      list.add(customer1);
      list.add(customer2);
      return list;
    } else {
      throw Exception("No trainees found");
    }
  }
} */

main() {
  setUp(() {
    Cache().setTestBaseUrl();
  });

  group('fetchPost', () {
    test('returns a List<Customer> if the http call completes successfully', () async {
      final client = CustomerApi();

      // Use Mockito to return a successful response when it calls the
      // provided http.Client.
      List<Customer> trainees = [];
      trainees = await client.getTrainees(62);

      expect(trainees.length, 2);
      expect(trainees[0].firstname, "Zalán");
    });

    test('throws an exception if the http call completes with an error', () async {
      final client = CustomerApi();

      expect(client.getTrainees(22), throwsException);
    });
  });
}
