Fakultas Ilmu Komputer UI

Commit b9648864 authored by Yoga Pratama's avatar Yoga Pratama
Browse files

[CHORES] Add mock for kegiatan terdekat repository

parent 6a86b7e6
Pipeline #77348 passed with stages
in 17 minutes and 53 seconds
......@@ -12,6 +12,7 @@ class KegiatanTerdekatRepository implements BaseKegiatanTerdekatRepository {
final response = await _network.get(
url: '/informasi-fasilitas/lokasi/kegiatan-terdekat', isLogin: false);
var kegiatan = KegiatanModel.fromJson(response);
print(response);
kegiatan.image = await fetchFotoKegiatan(kegiatan.placeId, kegiatan.id);
return kegiatan;
}
......
import 'package:bisaGo/model/kegiatan.dart';
import 'package:bisaGo/repository/kegiatan_terdekat_repository.dart';
import 'package:bisaGo/repository/lokasi_repository.dart';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
......@@ -23,6 +25,26 @@ class MockLokasiRepository extends Fake implements LokasiRepository {
};
}
class MockKegiatanTerdekatRepository extends Fake
implements KegiatanTerdekatRepository {
final mockKegiatan = {
'id': 4,
'place_id': 'ChIJz7ZP0RrsaS4RFfoglIJNTsk',
'creator': 'Rafif',
'nama_kegiatan': 'Makan Bersama',
'penyelenggara': 'Rafif',
'deskripsi': 'Test deksripsi',
'narahubung': '082178150021',
'time_start': '2021-07-01 04:26',
'time_end': '2021-07-02 00:57',
};
@override
Future fetchKegiatanTerdekatResponse() async {
return KegiatanModel.fromJson(mockKegiatan);
}
}
void main() {
group('Dashboard navigation tests', () {
NavigatorObserver mockObserver;
......@@ -50,6 +72,8 @@ void main() {
final _getIt = GetIt.instance;
_getIt.registerLazySingleton<BaseLokasiRepository>(
() => MockLokasiRepository());
_getIt.registerLazySingleton<BaseKegiatanTerdekatRepository>(
() => MockKegiatanTerdekatRepository());
});
Future<Null> _buildDashboardPage(WidgetTester tester) async {
......
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/kegiatan_terdekat_repository.dart';
import 'package:bisaGo/repository/komunitas_repository.dart';
import 'package:bisaGo/repository/lokasi_repository.dart';
import 'package:bisaGo/repository/sekolah_repository.dart';
......@@ -66,6 +68,26 @@ class MockSekolahRepository extends Fake implements SekolahRepository {
}
}
class MockKegiatanTerdekatRepository extends Fake
implements KegiatanTerdekatRepository {
final mockKegiatan = {
'id': 4,
'place_id': 'ChIJz7ZP0RrsaS4RFfoglIJNTsk',
'creator': 'Rafif',
'nama_kegiatan': 'Makan Bersama',
'penyelenggara': 'Rafif',
'deskripsi': 'Test deksripsi',
'narahubung': '082178150021',
'time_start': '2021-07-01 04:26',
'time_end': '2021-07-02 00:57',
};
@override
Future fetchKegiatanTerdekatResponse() async {
return KegiatanModel.fromJson(mockKegiatan);
}
}
void main() {
setUpAll(() {
final _getIt = GetIt.instance;
......@@ -75,6 +97,8 @@ void main() {
() => MockSekolahRepository());
_getIt.registerLazySingleton<BaseLokasiRepository>(
() => MockLokasiRepository());
_getIt.registerLazySingleton<BaseKegiatanTerdekatRepository>(
() => MockKegiatanTerdekatRepository());
});
testWidgets('finds a text field in dashboard', (WidgetTester tester) async {
final containerTextField = Key('Container Text Field');
......@@ -111,7 +135,7 @@ void main() {
testWidgets('finds a google map in dashboard', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: Dashboard()));
await tester.pump();
expect(find.byType(Container), findsNWidgets(8));
expect(find.byType(Container), findsNWidgets(12));
});
// testWidgets('finds a floating in dashboard', (WidgetTester tester) async {
......
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