Fakultas Ilmu Komputer UI

Commit c8a10fa9 authored by Dzaky Noor Hasyim's avatar Dzaky Noor Hasyim
Browse files

[RED] Add failing test for kegiatan_terdekat_button

parent 391bc1e0
Pipeline #76890 failed with stages
in 1 minute and 35 seconds
import 'package:bisaGo/config/strings.dart';
import 'package:bisaGo/model/kegiatan.dart';
import 'package:bisaGo/model/lokasi.dart';
import 'package:bisaGo/page/dashboard/dashboard.dart';
import 'package:bisaGo/page/filter_fasilitas/postingan/detail_post_kegiatan.dart';
import 'package:bisaGo/repository/kegiatan_repository.dart';
import 'package:bisaGo/repository/kegiatan_terdekat_repository.dart';
import 'package:bisaGo/repository/lokasi_repository.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get_it/get_it.dart';
class MockKegiatanTerdekat extends Fake implements KegiatanTerdekatRepository {
final mockKegiatan = {
'id': 2,
'nama_lokasi': 'Margo City',
'creator': 'Putri Salsabila',
'nama_kegiatan': 'Kopdar Rutin',
'penyelenggara': 'DTB Indonesia',
'narahubung': 'Putsal 08123123123',
'deskripsi': 'lorem ipsum dolor sit amet',
'time_start': '12-12-2021 06:30:00',
'time_end': '12-12-2021 09:30:00'
};
@override
Future fetchKegiatanTerdekatResponse() async {
return Future.value(KegiatanModel.fromJson(mockKegiatan));
}
}
class MockLokasi extends Fake implements LokasiRepository {
final mockLokasi = {
'name': 'Margo City',
'alamat': 'Jl. Margonda Raya No.358, Kemiri Muka, Kecamatan Beji, Kota Depok, Jawa Barat 16423',
'image': 'Margo.jpg',
'no_telp': '02178870888',
'counter': 69,
};
@override
Future<LokasiListResponse> fetchLokasi() async {
return Future.value(LokasiListResponse([Lokasi.fromJson(mockLokasi)]));
}
}
void main() {
final mockLokasi = {
'name': 'Margo City',
'alamat': 'Jl. Margonda Raya No.358, Kemiri Muka, Kecamatan Beji, Kota Depok, Jawa Barat 16423',
'image': 'Margo.jpg',
'no_telp': '02178870888',
'counter': 69,
};
final mockKegiatan = {
'id': 2,
'nama_lokasi': 'Margo City',
'creator': 'Putri Salsabila',
'nama_kegiatan': 'Kopdar Rutin',
'penyelenggara': 'DTB Indonesia',
'narahubung': 'Putsal 08123123123',
'deskripsi': 'lorem ipsum dolor sit amet',
'time_start': '12-12-2021 06:30:00',
'time_end': '12-12-2021 09:30:00'
};
setUpAll(() {
final _getIt = GetIt.instance;
_getIt.registerLazySingleton<BaseKegiatanTerdekatRepository>(
() => MockKegiatanTerdekat());
_getIt.registerLazySingleton<BaseLokasiRepository>(
() => MockLokasi());
});
testWidgets(
'Detail Post Kegiatan Page - Positive Test', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Dashboard()
));
await tester.pump();
expect(find.byType(Dashboard), findsOneWidget);
expect(find.text('Kopdar Rutin Test'), findsOneWidget);
});
}
\ No newline at end of file
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