Fakultas Ilmu Komputer UI

Commit 61e51b86 authored by Yoga Pratama's avatar Yoga Pratama
Browse files

[CHORES] Add mock fcm repository to several files

parent 061effe8
Pipeline #78260 passed with stages
in 12 minutes and 30 seconds
......@@ -18,9 +18,9 @@ void main() {
() => MockCloudMessagingRepository());
});
testWidgets('Generate fcm token', (WidgetTester tester) async {
final generatedUrl =
final result =
await MockCloudMessagingRepository().sendFCMToken('fcmToken', 'token');
expect(generatedUrl, true);
expect(result, true);
});
}
import 'package:bisaGo/model/kegiatan.dart';
import 'package:bisaGo/model/lokasi.dart';
import 'package:bisaGo/page/dashboard/dashboard.dart';
import 'package:bisaGo/repository/cloud_messaging_repository.dart';
import 'package:bisaGo/repository/kegiatan_terdekat_repository.dart';
import 'package:bisaGo/repository/lokasi_repository.dart';
import 'package:flutter/material.dart';
......@@ -41,6 +42,14 @@ class MockLokasi extends Fake implements LokasiRepository {
}
}
class MockCloudMessagingRepository extends Fake
implements CloudMessagingRepository {
@override
Future<bool> sendFCMToken(String fcmToken, String token) async {
return Future.value(true);
}
}
void main() {
// final mockLokasi = {
// 'name': 'Margo City',
......@@ -68,6 +77,8 @@ void main() {
_getIt.registerLazySingleton<BaseKegiatanTerdekatRepository>(
() => MockKegiatanTerdekat());
_getIt.registerLazySingleton<BaseLokasiRepository>(() => MockLokasi());
_getIt.registerLazySingleton<BaseCloudMessagingRepository>(
() => MockCloudMessagingRepository());
});
testWidgets('Detail Post Kegiatan Page - Positive Test',
......
import 'package:bisaGo/model/kegiatan.dart';
import 'package:bisaGo/repository/cloud_messaging_repository.dart';
import 'package:bisaGo/repository/kegiatan_terdekat_repository.dart';
import 'package:bisaGo/repository/lokasi_repository.dart';
import 'package:flutter/material.dart';
......@@ -45,6 +46,14 @@ class MockKegiatanTerdekatRepository extends Fake
}
}
class MockCloudMessagingRepository extends Fake
implements CloudMessagingRepository {
@override
Future<bool> sendFCMToken(String fcmToken, String token) async {
return Future.value(true);
}
}
void main() {
group('Dashboard navigation tests', () {
NavigatorObserver mockObserver;
......@@ -74,6 +83,8 @@ void main() {
() => MockLokasiRepository());
_getIt.registerLazySingleton<BaseKegiatanTerdekatRepository>(
() => MockKegiatanTerdekatRepository());
_getIt.registerLazySingleton<BaseCloudMessagingRepository>(
() => MockCloudMessagingRepository());
});
Future<Null> _buildDashboardPage(WidgetTester tester) async {
......
......@@ -2,6 +2,7 @@ import 'package:bisaGo/model/kegiatan.dart';
import 'package:bisaGo/model/komunitas.dart';
import 'package:bisaGo/model/lokasi.dart';
import 'package:bisaGo/model/sekolah.dart';
import 'package:bisaGo/repository/cloud_messaging_repository.dart';
import 'package:bisaGo/repository/kegiatan_terdekat_repository.dart';
import 'package:bisaGo/repository/komunitas_repository.dart';
import 'package:bisaGo/repository/lokasi_repository.dart';
......@@ -88,6 +89,14 @@ class MockKegiatanTerdekatRepository extends Fake
}
}
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;
......@@ -99,6 +108,8 @@ void main() {
() => MockLokasiRepository());
_getIt.registerLazySingleton<BaseKegiatanTerdekatRepository>(
() => MockKegiatanTerdekatRepository());
_getIt.registerLazySingleton<BaseCloudMessagingRepository>(
() => MockCloudMessagingRepository());
});
testWidgets('finds a text field in dashboard', (WidgetTester tester) async {
final containerTextField = Key('Container Text Field');
......
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