Fakultas Ilmu Komputer UI

Commit 528e06c9 authored by Yoga Pratama's avatar Yoga Pratama
Browse files

[RED] Implement test for fcm repository

parent ce7dbd1b
Pipeline #78257 passed with stages
in 12 minutes and 51 seconds
abstract class BaseCloudMessagingRepository {
Future<void> sendFCMToken(String fcmToken, String token);
}
class CloudMessagingRepository implements BaseCloudMessagingRepository {
@override
Future<bool> sendFCMToken(String fcmToken, String token) async {
return false;
}
}
import 'package:bisaGo/repository/cloud_messaging_repository.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get_it/get_it.dart';
import 'package:mockito/mockito.dart';
class MockCloudMessagingRepository extends Fake
implements CloudMessagingRepository {
@override
Future<bool> sendFCMToken(String fcmToken, String token) async {
return Future.value(true);
}
}
void main() {
setUpAll(() {
final _getIt = GetIt.instance;
_getIt.registerLazySingleton<BaseCloudMessagingRepository>(
() => MockCloudMessagingRepository());
});
testWidgets('Generate fcm token', (WidgetTester tester) async {
final generatedUrl =
await MockCloudMessagingRepository().sendFCMToken('fcmToken', 'token');
expect(generatedUrl, true);
});
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment