- Implement EmergencyService for handling emergency contacts per trip. - Create GuestFlagService to manage guest mode flags for trips. - Introduce NotificationService with local notification capabilities. - Add OfflineFlagService for managing offline caching flags. - Develop PackingService for shared packing lists per trip. - Implement ReminderService for managing reminders/to-dos per trip. - Create SosService for dispatching SOS events to a backend. - Add StorageService with album image upload functionality. - Implement TransportService for managing transport segments per trip. - Create TripChecklistService for storing and retrieving trip checklists. - Add TripDocumentService for persisting trip documents metadata. test: Add unit tests for new services - Implement tests for AlbumService, BudgetService, EmergencyService, GuestFlagService, PackingService, ReminderService, SosService, TransportService, TripChecklistService, and TripDocumentService. - Ensure tests cover adding, loading, deleting, and handling corrupted payloads for each service.
40 lines
1.2 KiB
Dart
40 lines
1.2 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:travel_mate/models/album_photo.dart';
|
|
import 'package:travel_mate/services/album_service.dart';
|
|
|
|
void main() {
|
|
const tripId = 'trip-album-1';
|
|
late AlbumService service;
|
|
|
|
setUp(() {
|
|
SharedPreferences.setMockInitialValues({});
|
|
service = AlbumService();
|
|
});
|
|
|
|
test('adds and loads photos', () async {
|
|
final photo = AlbumPhoto.newPhoto(
|
|
id: 'p1',
|
|
url: 'https://example.com/img.jpg',
|
|
caption: 'Coucher de soleil',
|
|
uploadedBy: 'Alice',
|
|
);
|
|
await service.addPhoto(tripId, photo);
|
|
final loaded = await service.loadPhotos(tripId);
|
|
expect(loaded.single.url, contains('example.com'));
|
|
});
|
|
|
|
test('deletes photo and clears corrupted payload', () async {
|
|
final p = AlbumPhoto.newPhoto(id: 'p1', url: 'u', caption: null);
|
|
await service.addPhoto(tripId, p);
|
|
var updated = await service.deletePhoto(tripId, 'p1');
|
|
expect(updated, isEmpty);
|
|
|
|
final prefs = await SharedPreferences.getInstance();
|
|
await prefs.setString('album_$tripId', 'oops');
|
|
updated = await service.loadPhotos(tripId);
|
|
expect(updated, isEmpty);
|
|
expect(prefs.getString('album_$tripId'), isNull);
|
|
});
|
|
}
|