All checks were successful
Release / meta (push) Successful in 3s
Release / linux-build (push) Successful in 1m1s
Release / web-build (push) Successful in 1m22s
Release / android-build (push) Successful in 6m49s
Release / release-master (push) Successful in 5s
Release / release-dev (push) Successful in 8s
61 lines
1.8 KiB
Dart
61 lines
1.8 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:mileograph_flutter/components/pages/legs.dart';
|
|
import 'package:mileograph_flutter/services/distance_unit_service.dart';
|
|
|
|
import '../helpers/fake_services.dart';
|
|
import '../helpers/test_app.dart';
|
|
import '../helpers/test_data.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
setUpAll(() {
|
|
SharedPreferences.setMockInitialValues({});
|
|
});
|
|
|
|
testWidgets('Entries page shows legs and mileage summary', (tester) async {
|
|
final data = FakeDataService()..legsValue = TestData.legs;
|
|
final auth = FakeAuthService(api: FakeApiService());
|
|
final distanceUnits = FakeDistanceUnitService(
|
|
unitOverride: DistanceUnit.milesDecimal,
|
|
);
|
|
|
|
await tester.pumpWidget(
|
|
buildTestApp(
|
|
child: const LegsPage(),
|
|
dataService: data,
|
|
authService: auth,
|
|
distanceUnitService: distanceUnits,
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Entries'), findsOneWidget);
|
|
expect(find.text('Page mileage'), findsOneWidget);
|
|
expect(find.textContaining('mi'), findsWidgets);
|
|
expect(find.text('London'), findsOneWidget);
|
|
expect(find.text('Oxford'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('Entries page shows empty state', (tester) async {
|
|
final data = FakeDataService()
|
|
..legsValue = []
|
|
..isLegsLoadingValue = false;
|
|
final auth = FakeAuthService(api: FakeApiService());
|
|
|
|
await tester.pumpWidget(
|
|
buildTestApp(
|
|
child: const LegsPage(),
|
|
dataService: data,
|
|
authService: auth,
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('No entries found'), findsOneWidget);
|
|
expect(find.text('Adjust the filters or add a new leg.'), findsOneWidget);
|
|
});
|
|
}
|