mirror of
https://github.com/flutter/samples.git
synced 2026-04-22 15:03:35 +00:00
Flutter 3.29 beta (#2571)
This commit is contained in:
@@ -18,9 +18,7 @@ void main() {
|
||||
|
||||
setUp(() {
|
||||
fakeApiClient = FakeApiClient();
|
||||
bookingRepository = BookingRepositoryRemote(
|
||||
apiClient: fakeApiClient,
|
||||
);
|
||||
bookingRepository = BookingRepositoryRemote(apiClient: fakeApiClient);
|
||||
});
|
||||
|
||||
test('should get booking', () async {
|
||||
|
||||
@@ -37,8 +37,9 @@ void main() {
|
||||
'/destination/${kDestination1.ref}/activity',
|
||||
activites,
|
||||
);
|
||||
final result =
|
||||
await apiClient.getActivityByDestination(kDestination1.ref);
|
||||
final result = await apiClient.getActivityByDestination(
|
||||
kDestination1.ref,
|
||||
);
|
||||
expect(result.asOk.value, activites);
|
||||
});
|
||||
|
||||
|
||||
@@ -21,20 +21,10 @@ void main() {
|
||||
});
|
||||
|
||||
test('should post login', () async {
|
||||
const loginResponse = LoginResponse(
|
||||
token: 'TOKEN',
|
||||
userId: '123',
|
||||
);
|
||||
mockHttpClient.mockPost(
|
||||
'/login',
|
||||
loginResponse,
|
||||
200,
|
||||
);
|
||||
const loginResponse = LoginResponse(token: 'TOKEN', userId: '123');
|
||||
mockHttpClient.mockPost('/login', loginResponse, 200);
|
||||
final result = await apiClient.login(
|
||||
const LoginRequest(
|
||||
email: 'EMAIL',
|
||||
password: 'PASSWORD',
|
||||
),
|
||||
const LoginRequest(email: 'EMAIL', password: 'PASSWORD'),
|
||||
);
|
||||
expect(result.asOk.value, loginResponse);
|
||||
});
|
||||
|
||||
@@ -60,8 +60,9 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('should select activity and confirm',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('should select activity and confirm', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await mockNetworkImages(() async {
|
||||
await loadScreen(tester);
|
||||
// Select one activity
|
||||
|
||||
@@ -20,9 +20,7 @@ void main() {
|
||||
|
||||
setUp(() {
|
||||
fakeAuthRepository = FakeAuthRepository();
|
||||
viewModel = LoginViewModel(
|
||||
authRepository: fakeAuthRepository,
|
||||
);
|
||||
viewModel = LoginViewModel(authRepository: fakeAuthRepository);
|
||||
goRouter = MockGoRouter();
|
||||
});
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ void main() {
|
||||
fakeAuthRepository.token = 'TOKEN';
|
||||
// Setup an ItineraryConfig with some data, should be cleared after logout
|
||||
fakeItineraryConfigRepository = FakeItineraryConfigRepository(
|
||||
itineraryConfig: const ItineraryConfig(continent: 'CONTINENT'));
|
||||
itineraryConfig: const ItineraryConfig(continent: 'CONTINENT'),
|
||||
);
|
||||
viewModel = LogoutViewModel(
|
||||
authRepository: fakeAuthRepository,
|
||||
itineraryConfigRepository: fakeItineraryConfigRepository,
|
||||
|
||||
@@ -84,8 +84,9 @@ void main() {
|
||||
expect(find.text(kBooking.destination.tags.first), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should create booking from itinerary config',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('should create booking from itinerary config', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await loadScreen(tester);
|
||||
|
||||
// Create a new booking from stored itinerary config
|
||||
|
||||
@@ -62,8 +62,9 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('should tap and navigate to activities',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('should tap and navigate to activities', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await mockNetworkImages(() async {
|
||||
await loadScreen(tester);
|
||||
|
||||
|
||||
@@ -25,8 +25,9 @@ void main() {
|
||||
await testApp(tester, SearchFormContinent(viewModel: viewModel));
|
||||
}
|
||||
|
||||
testWidgets('Should load and select continent',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Should load and select continent', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await loadWidget(tester);
|
||||
expect(find.byType(SearchFormContinent), findsOneWidget);
|
||||
|
||||
|
||||
@@ -26,8 +26,9 @@ void main() {
|
||||
await testApp(tester, SearchFormDate(viewModel: viewModel));
|
||||
}
|
||||
|
||||
testWidgets('should display date in different month',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('should display date in different month', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await loadWidget(tester);
|
||||
expect(find.byType(SearchFormDate), findsOneWidget);
|
||||
|
||||
@@ -36,14 +37,17 @@ void main() {
|
||||
|
||||
// Simulate date picker input:
|
||||
viewModel.dateRange = DateTimeRange(
|
||||
start: DateTime(2024, 6, 12), end: DateTime(2024, 7, 23));
|
||||
start: DateTime(2024, 6, 12),
|
||||
end: DateTime(2024, 7, 23),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('12 Jun - 23 Jul'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should display date in same month',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('should display date in same month', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await loadWidget(tester);
|
||||
expect(find.byType(SearchFormDate), findsOneWidget);
|
||||
|
||||
@@ -52,7 +56,9 @@ void main() {
|
||||
|
||||
// Simulate date picker input:
|
||||
viewModel.dateRange = DateTimeRange(
|
||||
start: DateTime(2024, 6, 12), end: DateTime(2024, 6, 23));
|
||||
start: DateTime(2024, 6, 12),
|
||||
end: DateTime(2024, 6, 23),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('12 - 23 Jun'), findsOneWidget);
|
||||
|
||||
@@ -46,8 +46,9 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('Should fill form and perform search',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Should fill form and perform search', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await loadWidget(tester);
|
||||
expect(find.byType(SearchFormScreen), findsOneWidget);
|
||||
|
||||
@@ -56,7 +57,9 @@ void main() {
|
||||
|
||||
// Select date
|
||||
viewModel.dateRange = DateTimeRange(
|
||||
start: DateTime(2024, 6, 12), end: DateTime(2024, 7, 23));
|
||||
start: DateTime(2024, 6, 12),
|
||||
end: DateTime(2024, 7, 23),
|
||||
);
|
||||
|
||||
// Select guests
|
||||
await tester.tap(find.byKey(const ValueKey(addGuestsKey)));
|
||||
|
||||
@@ -66,8 +66,9 @@ void main() {
|
||||
});
|
||||
|
||||
test('should handle errors', () async {
|
||||
final command =
|
||||
Command0<int>(() => Future.value(Result.error(Exception('ERROR!'))));
|
||||
final command = Command0<int>(
|
||||
() => Future.value(Result.error(Exception('ERROR!'))),
|
||||
);
|
||||
await command.execute();
|
||||
expect(command.error, true);
|
||||
expect(command.result, isA<Error>());
|
||||
@@ -90,8 +91,9 @@ void main() {
|
||||
|
||||
test('should complete bool command, bool argument', () async {
|
||||
// Action that returns bool argument
|
||||
final command =
|
||||
Command1<bool, bool>((a) => Future.value(const Result.ok(true)));
|
||||
final command = Command1<bool, bool>(
|
||||
(a) => Future.value(const Result.ok(true)),
|
||||
);
|
||||
|
||||
// Run action with result and argument
|
||||
await command.execute(true);
|
||||
|
||||
Reference in New Issue
Block a user