mirror of
https://github.com/flutter/samples.git
synced 2025-11-13 10:59:04 +00:00
Compass app (#2446)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// Copyright 2024 The Flutter team. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:compass_app/domain/use_cases/booking/booking_create_use_case.dart';
|
||||
import 'package:compass_app/domain/models/itinerary_config/itinerary_config.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../../../testing/fakes/repositories/fake_activities_repository.dart';
|
||||
import '../../../../testing/fakes/repositories/fake_booking_repository.dart';
|
||||
import '../../../../testing/fakes/repositories/fake_destination_repository.dart';
|
||||
import '../../../../testing/models/activity.dart';
|
||||
import '../../../../testing/models/booking.dart';
|
||||
import '../../../../testing/models/destination.dart';
|
||||
|
||||
void main() {
|
||||
group('BookingCreateUseCase tests', () {
|
||||
test('Create booking', () async {
|
||||
final useCase = BookingCreateUseCase(
|
||||
activityRepository: FakeActivityRepository(),
|
||||
destinationRepository: FakeDestinationRepository(),
|
||||
bookingRepository: FakeBookingRepository(),
|
||||
);
|
||||
|
||||
final booking = await useCase.createFrom(
|
||||
ItineraryConfig(
|
||||
startDate: DateTime(2024, 01, 01),
|
||||
endDate: DateTime(2024, 02, 12),
|
||||
destination: kDestination1.ref,
|
||||
activities: [kActivity.ref],
|
||||
),
|
||||
);
|
||||
|
||||
expect(booking.asOk.value, kBooking);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright 2024 The Flutter team. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:compass_app/domain/use_cases/booking/booking_share_use_case.dart';
|
||||
import 'package:compass_app/domain/models/booking/booking.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../../../testing/models/activity.dart';
|
||||
import '../../../../testing/models/destination.dart';
|
||||
|
||||
void main() {
|
||||
group('BookingShareUseCase tests', () {
|
||||
test('Share booking', () async {
|
||||
String? sharedText;
|
||||
final useCase = BookingShareUseCase.custom((text) async {
|
||||
sharedText = text;
|
||||
});
|
||||
final booking = Booking(
|
||||
startDate: DateTime(2024, 01, 01),
|
||||
endDate: DateTime(2024, 02, 12),
|
||||
destination: kDestination1,
|
||||
activity: [kActivity],
|
||||
);
|
||||
await useCase.shareBooking(booking);
|
||||
expect(
|
||||
sharedText,
|
||||
'Trip to name1\n'
|
||||
'on 1 Jan - 12 Feb\n'
|
||||
'Activities:\n'
|
||||
' - NAME.',
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user