Fakultas Ilmu Komputer UI

Commit 23b1867f authored by Fakhira Devina's avatar Fakhira Devina
Browse files

[CHORE] add todo for testing

parent 4f691206
Pipeline #37201 failed with stages
in 3 minutes and 28 seconds
import 'dart:convert';
import 'package:ppl_disabilitas/config/strings.dart';
import 'package:ppl_disabilitas/network/CustomException.dart';
import 'package:ppl_disabilitas/network/data/network_model.dart';
import 'package:http/http.dart' as http;
import 'dart:io';
import 'cookies_interface.dart';
class NetworkInterface {
//String key = KEY;
......
......@@ -85,7 +85,7 @@ class PencarianState extends State<Pencarian> {
displayWidget = Center(
child: Text("Anda belum pernah melakukan pencarian"));
} else {
displayWidget = makeLokasiWidget(recentSearch);
displayWidget = makeLokasiWidget("history",recentSearch);
}
return Expanded(
child: Column(
......@@ -131,7 +131,7 @@ class PencarianState extends State<Pencarian> {
case Status.COMPLETED:
lokasiFromApi = snapshot.data.data;
return Expanded(
flex: 2, child: makeLokasiWidget(lokasiFromApi));
flex: 2, child: makeLokasiWidget("api",lokasiFromApi));
break;
case Status.ERROR:
return Center(
......@@ -148,12 +148,13 @@ class PencarianState extends State<Pencarian> {
);
}
Widget makeLokasiWidget(LokasiListResponse places) {
Widget makeLokasiWidget(String key, LokasiListResponse places) {
return ListView.builder(
shrinkWrap: true,
itemCount: places.listLokasi.length,
itemBuilder: (context, index) {
return InkWell(
key: Key("$key-${places.listLokasi[index].nama}"),
onTap: () {
_bloc.saveRecentSearch(places.listLokasi[index]);
},
......
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:mockito/mockito.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:ppl_disabilitas/bloc/LokasiResponseBloc.dart';
import 'package:ppl_disabilitas/network/network_interface.dart';
import 'package:ppl_disabilitas/page/dashboard/dashboard.dart';
......@@ -15,7 +13,6 @@ void main() {
NavigatorObserver mockObserver;
NetworkInterface mockNetwork;
setUp(() {
//final lokasiBloc = LokasiResponseBloc();
mockObserver = MockNavigatorObserver();
mockNetwork = MockNetwork();
when(mockNetwork.get(isLogin: false, url: anyNamed('url'))).thenAnswer((_) async {
......
......@@ -6,15 +6,41 @@
// tree, read text, and verify that the values of widget properties are correct.
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:ppl_disabilitas/page/pencarian/pencarian.dart';
import 'package:ppl_disabilitas/network/network_interface.dart';
class MockNetwork extends Mock implements NetworkInterface {}
void main() {
MockNetwork mockNetwork;
setUp(() {
mockNetwork = MockNetwork();
when(mockNetwork.get(isLogin: false, url: anyNamed('url'))).thenAnswer((_) async {
await Future.delayed(Duration(milliseconds: 50));
return Future<dynamic>.value(
[
{
"nama": "Coolidge",
"latitude": -23.7169139,
"longitude": -46.8498038,
"alamat": "74809 Hooker Drive",
"telepon": "+55 956 836 5799"
}
]
);
});
});
testWidgets('display list view in pencarian', (WidgetTester tester) async {
// Provide the childWidget to the Container.
await tester.pumpWidget(MaterialApp(home: Pencarian()));
// [TODO] pencet textfieldnya, isi textfieldnya pake Coolidge
// [TODO] expect nya keluar satu item namanya coolidge, expectnya pake key aja
// [TODO] tiap item itu punya key unik
// Search for the childWidget in the tree and verify it exists.
//expect(find.byType(ListView), findsNWidgets);
//expect(find.byType(Container), findsWidgets);
......
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