cofounderella/test/location_selector_test.dart

58 lines
2.1 KiB
Dart

import 'package:cofounderella/components/location_selector.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('LocationSelector Widget Tests', () {
testWidgets('LocationSelector widget renders correctly',
(WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Scaffold(
body: LocationSelector(
onLocationChanged: (location) {},
),
),
));
expect(find.text('Search location'), findsOneWidget);
expect(find.text('Country: '), findsOneWidget);
expect(find.text('City: '), findsOneWidget);
expect(find.text('Postal Code: '), findsOneWidget);
expect(find.text('Street: '), findsOneWidget);
expect(find.text('State/Area: '), findsOneWidget);
expect(find.text('Latitude: --'), findsOneWidget);
expect(find.text('Longitude: --'), findsOneWidget);
});
// TODO CPD Testing
//
// testWidgets('Search for Berlin and check output', (WidgetTester tester) async {
// await tester.pumpWidget(MaterialApp(
// home: Scaffold(
// body: LocationSelector(
// onLocationChanged: (location) {},
// ),
// ),
// ));
//
// await tester.enterText(find.byType(TextField), 'Berlin');
// await tester.pump();
//
// await tester.tap(find.byIcon(Icons.search));
// await tester.pumpAndSettle();
//
// expect(find.text('City: Berlin'), findsOneWidget);
// expect(find.text('Country: Germany'), findsOneWidget);
// });
//
// fails with
//
// Warning: At least one test in this suite creates an HttpClient. When running a test suite that uses
// TestWidgetsFlutterBinding, all HTTP requests will return status code 400, and no network request
// will actually be made. Any test expecting a real network connection and status code will fail.
// To test code that needs an HttpClient, provide your own HttpClient implementation to the code under
// test, so that your test can consistently provide a testable response to the code under test.
//
});
}