- 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.
38 lines
1.1 KiB
Dart
38 lines
1.1 KiB
Dart
import 'dart:convert';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:http/http.dart' as http;
|
|
import 'package:http/testing.dart';
|
|
import 'package:travel_mate/services/sos_service.dart';
|
|
|
|
void main() {
|
|
test('sendSos returns true on 200', () async {
|
|
final mockClient = MockClient((request) async {
|
|
expect(request.url.toString(), 'https://api.example.com/sos');
|
|
final body = json.decode(request.body) as Map<String, dynamic>;
|
|
expect(body['tripId'], 't1');
|
|
return http.Response('{}', 200);
|
|
});
|
|
|
|
final service = SosService(
|
|
baseUrl: 'https://api.example.com',
|
|
client: mockClient,
|
|
);
|
|
|
|
final result = await service.sendSos(tripId: 't1', lat: 1, lng: 2);
|
|
expect(result, isTrue);
|
|
});
|
|
|
|
test('sendSos returns false on error', () async {
|
|
final mockClient = MockClient((request) async {
|
|
return http.Response('fail', 500);
|
|
});
|
|
final service = SosService(
|
|
baseUrl: 'https://api.example.com',
|
|
client: mockClient,
|
|
);
|
|
|
|
final result = await service.sendSos(tripId: 't1', lat: 0, lng: 0);
|
|
expect(result, isFalse);
|
|
});
|
|
}
|