Fakultas Ilmu Komputer UI

Commit 011d1017 authored by wibias fuad's avatar wibias fuad
Browse files

test: change test again, using main_test

parent 981deeca
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_keyboard_visibility","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility-5.0.0\\\\","dependencies":[]},{"name":"flutter_secure_storage","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_secure_storage-3.3.5\\\\","dependencies":[]},{"name":"image_picker","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.7.4\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-2.0.1\\\\","dependencies":[]}],"android":[{"name":"flutter_keyboard_visibility","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility-5.0.0\\\\","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-2.0.1\\\\","dependencies":[]},{"name":"flutter_secure_storage","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_secure_storage-3.3.5\\\\","dependencies":[]},{"name":"image_picker","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.7.4\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"path_provider","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-2.0.1\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-2.0.0\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-2.0.0\\\\","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-2.0.0\\\\","dependencies":[]}],"web":[{"name":"flutter_keyboard_visibility_web","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility_web-2.0.0\\\\","dependencies":[]},{"name":"image_picker_for_web","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_for_web-2.0.0\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_keyboard_visibility","dependencies":["flutter_keyboard_visibility_web"]},{"name":"flutter_keyboard_visibility_web","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"flutter_secure_storage","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle","image_picker_for_web"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2021-05-17 08:40:25.559535","version":"2.0.3"}
\ No newline at end of file
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_keyboard_visibility","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility-5.0.0\\\\","dependencies":[]},{"name":"flutter_secure_storage","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_secure_storage-3.3.5\\\\","dependencies":[]},{"name":"image_picker","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.7.4\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-2.0.1\\\\","dependencies":[]}],"android":[{"name":"flutter_keyboard_visibility","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility-5.0.0\\\\","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-2.0.1\\\\","dependencies":[]},{"name":"flutter_secure_storage","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_secure_storage-3.3.5\\\\","dependencies":[]},{"name":"image_picker","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.7.4\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"path_provider","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-2.0.1\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-2.0.0\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-2.0.0\\\\","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-2.0.0\\\\","dependencies":[]}],"web":[{"name":"flutter_keyboard_visibility_web","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_keyboard_visibility_web-2.0.0\\\\","dependencies":[]},{"name":"image_picker_for_web","path":"C:\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_for_web-2.0.0\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_keyboard_visibility","dependencies":["flutter_keyboard_visibility_web"]},{"name":"flutter_keyboard_visibility_web","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"flutter_secure_storage","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle","image_picker_for_web"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2021-05-17 08:52:38.494237","version":"2.0.3"}
\ No newline at end of file
......@@ -382,187 +382,47 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fundex_app/pages/kyc/alamat_body.dart';
import 'package:fundex_app/main-screen.dart';
void main() {
testWidgets('Page mempunyai app bar', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.byIcon(Icons.arrow_back), findsOneWidget);
expect(find.text('e-KYC Pemodal'), findsOneWidget);
Widget createWidgetForTesting({Widget child}) {
return MaterialApp(
home: child,
);
}
testWidgets('Testing bottom navigation bar', (WidgetTester tester) async {
await tester.pumpWidget(createWidgetForTesting(child: MainScreen()));
expect(find.byKey(Key('bottomNavigationBar')), findsOneWidget);
});
testWidgets('Terdapat Checkpoint', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.byKey(Key("checkpoint")), findsOneWidget);
expect(find.byKey(Key("line")), findsOneWidget);
testWidgets('Testing home icon on bottom navbar',
(WidgetTester tester) async {
await tester.pumpWidget(createWidgetForTesting(child: MainScreen()));
expect(find.byKey(Key('homeIcon')), findsOneWidget);
});
testWidgets('Terdapat text alamat', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.byKey(Key('teksAlamat')), findsOneWidget);
expect(find.text('Alamat Lengkap Sesuai KTP *'), findsOneWidget);
testWidgets('Testing portfolio icon on bottom navbar',
(WidgetTester tester) async {
await tester.pumpWidget(createWidgetForTesting(child: MainScreen()));
expect(find.byKey(Key('portfolioIcon')), findsOneWidget);
});
test('Field alamat tidak diisi', (){
var tes = ValidasiAlamat.validate('');
expect(tes, 'Alamat harus di isi');
testWidgets('Testing transaction icon on bottom navbar',
(WidgetTester tester) async {
await tester.pumpWidget(createWidgetForTesting(child: MainScreen()));
expect(find.byKey(Key('transactionIcon')), findsOneWidget);
});
test('Field alamat diisi', (){
var tes = ValidasiAlamat.validate('Jl. Raya gede banget');
expect(tes, null);
testWidgets('Testing help icon on bottom navbar',
(WidgetTester tester) async {
await tester.pumpWidget(createWidgetForTesting(child: MainScreen()));
expect(find.byKey(Key('helpIcon')), findsOneWidget);
});
testWidgets('Terdapat text kode pos', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.text('Kode Pos *'), findsOneWidget);
testWidgets('Testing account icon on bottom navbar',
(WidgetTester tester) async {
await tester.pumpWidget(createWidgetForTesting(child: MainScreen()));
expect(find.byKey(Key('accountIcon')), findsOneWidget);
});
test('Field kode pos tidak diisi', (){
var tes = ValidasiKodePos.validate('');
expect(tes, 'kode pos harus di isi');
});
test('kode pos tidak valid', (){
var tes = ValidasiKodePos.validate('147qwer');
expect(tes, 'kode pos tidak valid');
});
test('Field kode pos diisi', (){
var tes = ValidasiKodePos.validate('1475302');
expect(tes, null);
});
testWidgets('typeAHead berhasil', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.text("Provinsi *"), findsOneWidget);
final typeAHead = find.byKey(Key('typeahead'));
expect(typeAHead, findsOneWidget);
await tester.tap(typeAHead);
await tester.enterText(typeAHead, 'DKI Jakarta');
await tester.tap(typeAHead);
await tester.pump();
expect(find.text('DKI Jakarta'), findsWidgets);
});
test('Field Tempat Lahir tidak diisi', (){
var tes = ValidasiTempat.validate('');
expect(tes, 'Provinsi harus di isi');
});
test('Field Tempat Lahir diisi', (){
var tes = ValidasiTempat.validate('DKI Jakarta');
expect(tes, null);
});
testWidgets('typeAHead kabupaten berhasil', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.text("Kabupaten / Kota *"), findsOneWidget);
final typeAHead = find.byKey(Key('typeaheadKabupaten'));
expect(typeAHead, findsOneWidget);
await tester.tap(typeAHead);
await tester.enterText(typeAHead, 'Jakarta Timur');
await tester.tap(typeAHead);
await tester.pump();
expect(find.text('Jakarta Timur'), findsWidgets);
});
test('Field Kabupaten tidak diisi', (){
var tes = ValidasiKabupaten.validate('');
expect(tes, 'Kabupaten harus di isi');
});
test('Field Kabupaten diisi', (){
var tes = ValidasiKabupaten.validate('Jakarta Timur');
expect(tes, null);
});
testWidgets('typeAHead kecamatan berhasil', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.text("Kecamatan *"), findsOneWidget);
final typeAHead = find.byKey(Key('typeaheadKecamatan'));
expect(typeAHead, findsOneWidget);
await tester.tap(typeAHead);
await tester.enterText(typeAHead, 'Ciracas');
await tester.tap(typeAHead);
await tester.pump();
expect(find.text('Ciracas'), findsWidgets);
});
test('Field Kecamatan tidak diisi', (){
var tes = ValidasiKecamatan.validate('');
expect(tes, 'Kecamatan harus di isi');
});
test('Field Kecamatan diisi', (){
var tes = ValidasiKecamatan.validate('Ciracas');
expect(tes, null);
});
testWidgets('typeAHead kelurahan berhasil', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.text("Kelurahan *"), findsOneWidget);
final typeAHead = find.byKey(Key('typeaheadKelurahan'));
expect(typeAHead, findsOneWidget);
await tester.tap(typeAHead);
await tester.enterText(typeAHead, 'Ciracas');
await tester.tap(typeAHead);
await tester.pump();
expect(find.text('Ciracas'), findsWidgets);
});
test('Field Kecamatan tidak diisi', (){
var tes = ValidasiKelurahan.validate('');
expect(tes, 'Kelurahan harus di isi');
});
test('Field Kecamatan diisi', (){
var tes = ValidasiKelurahan.validate('Ciracas');
expect(tes, null);
});
testWidgets('checkbox berhasil', (WidgetTester tester) async {
bool _checkBox = false;
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.text('Alamat domisili tidak sesuai dengan KTP'), findsOneWidget);
await tester.tap(find.byType(Checkbox));
await tester.pumpAndSettle();
expect(_checkBox, false);
_checkBox = true;
await tester.pumpAndSettle();
expect(_checkBox, true);
});
testWidgets('Button selanjutnya', (WidgetTester tester) async {
final buttonSelanjutnya = find.byKey(Key('selanjutnyaButton'));
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(buttonSelanjutnya, findsOneWidget);
expect(find.text("Selanjutnya"), findsOneWidget);
await tester.tap(buttonSelanjutnya);
await tester.pumpAndSettle();
});
testWidgets('Button sebelumnya', (WidgetTester tester) async {
final buttonSebelumnya= find.byKey(Key('sebelumnyaButton'));
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(buttonSebelumnya, findsOneWidget);
expect(find.text("Sebelumnya"), findsOneWidget);
await tester.tap(buttonSebelumnya);
await tester.pumpAndSettle();
});
}
\ No newline at end of file
}
......@@ -72,187 +72,48 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fundex_app/pages/kyc/alamat_body.dart';
import 'package:fundex_app/main-screen.dart';
void main() {
testWidgets('Page mempunyai app bar', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.byIcon(Icons.arrow_back), findsOneWidget);
expect(find.text('e-KYC Pemodal'), findsOneWidget);
});
testWidgets('Terdapat Checkpoint', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.byKey(Key("checkpoint")), findsOneWidget);
expect(find.byKey(Key("line")), findsOneWidget);
});
testWidgets('Terdapat text alamat', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.byKey(Key('teksAlamat')), findsOneWidget);
expect(find.text('Alamat Lengkap Sesuai KTP *'), findsOneWidget);
});
test('Field alamat tidak diisi', (){
var tes = ValidasiAlamat.validate('');
expect(tes, 'Alamat harus di isi');
});
test('Field alamat diisi', (){
var tes = ValidasiAlamat.validate('Jl. Raya gede banget');
expect(tes, null);
});
testWidgets('Terdapat text kode pos', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.text('Kode Pos *'), findsOneWidget);
});
test('Field kode pos tidak diisi', (){
var tes = ValidasiKodePos.validate('');
expect(tes, 'kode pos harus di isi');
});
test('kode pos tidak valid', (){
var tes = ValidasiKodePos.validate('147qwer');
expect(tes, 'kode pos tidak valid');
});
test('Field kode pos diisi', (){
var tes = ValidasiKodePos.validate('1475302');
expect(tes, null);
});
testWidgets('typeAHead berhasil', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.text("Provinsi *"), findsOneWidget);
final typeAHead = find.byKey(Key('typeahead'));
expect(typeAHead, findsOneWidget);
await tester.tap(typeAHead);
await tester.enterText(typeAHead, 'DKI Jakarta');
await tester.tap(typeAHead);
await tester.pump();
expect(find.text('DKI Jakarta'), findsWidgets);
});
test('Field Tempat Lahir tidak diisi', (){
var tes = ValidasiTempat.validate('');
expect(tes, 'Provinsi harus di isi');
});
test('Field Tempat Lahir diisi', (){
var tes = ValidasiTempat.validate('DKI Jakarta');
expect(tes, null);
});
testWidgets('typeAHead kabupaten berhasil', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.text("Kabupaten / Kota *"), findsOneWidget);
Widget createWidgetForTesting({Widget child}) {
return MaterialApp(
home: child,
);
}
final typeAHead = find.byKey(Key('typeaheadKabupaten'));
expect(typeAHead, findsOneWidget);
await tester.tap(typeAHead);
await tester.enterText(typeAHead, 'Jakarta Timur');
await tester.tap(typeAHead);
await tester.pump();
expect(find.text('Jakarta Timur'), findsWidgets);
testWidgets('Testing bottom navigation bar', (WidgetTester tester) async {
await tester.pumpWidget(createWidgetForTesting(child: MainScreen()));
expect(find.byKey(Key('bottomNavigationBar')), findsOneWidget);
});
test('Field Kabupaten tidak diisi', (){
var tes = ValidasiKabupaten.validate('');
expect(tes, 'Kabupaten harus di isi');
});
test('Field Kabupaten diisi', (){
var tes = ValidasiKabupaten.validate('Jakarta Timur');
expect(tes, null);
testWidgets('Testing home icon on bottom navbar',
(WidgetTester tester) async {
await tester.pumpWidget(createWidgetForTesting(child: MainScreen()));
expect(find.byKey(Key('homeIcon')), findsOneWidget);
});
testWidgets('typeAHead kecamatan berhasil', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.text("Kecamatan *"), findsOneWidget);
final typeAHead = find.byKey(Key('typeaheadKecamatan'));
expect(typeAHead, findsOneWidget);
await tester.tap(typeAHead);
await tester.enterText(typeAHead, 'Ciracas');
await tester.tap(typeAHead);
await tester.pump();
expect(find.text('Ciracas'), findsWidgets);
testWidgets('Testing portfolio icon on bottom navbar',
(WidgetTester tester) async {
await tester.pumpWidget(createWidgetForTesting(child: MainScreen()));
expect(find.byKey(Key('portfolioIcon')), findsOneWidget);
});
test('Field Kecamatan tidak diisi', (){
var tes = ValidasiKecamatan.validate('');
expect(tes, 'Kecamatan harus di isi');
testWidgets('Testing transaction icon on bottom navbar',
(WidgetTester tester) async {
await tester.pumpWidget(createWidgetForTesting(child: MainScreen()));
expect(find.byKey(Key('transactionIcon')), findsOneWidget);
});
test('Field Kecamatan diisi', (){
var tes = ValidasiKecamatan.validate('Ciracas');
expect(tes, null);
});
testWidgets('typeAHead kelurahan berhasil', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.text("Kelurahan *"), findsOneWidget);
final typeAHead = find.byKey(Key('typeaheadKelurahan'));
expect(typeAHead, findsOneWidget);
await tester.tap(typeAHead);
await tester.enterText(typeAHead, 'Ciracas');
await tester.tap(typeAHead);
await tester.pump();
expect(find.text('Ciracas'), findsWidgets);
});
test('Field Kecamatan tidak diisi', (){
var tes = ValidasiKelurahan.validate('');
expect(tes, 'Kelurahan harus di isi');
});
test('Field Kecamatan diisi', (){
var tes = ValidasiKelurahan.validate('Ciracas');
expect(tes, null);
});
testWidgets('checkbox berhasil', (WidgetTester tester) async {
bool _checkBox = false;
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.text('Alamat domisili tidak sesuai dengan KTP'), findsOneWidget);
await tester.tap(find.byType(Checkbox));
await tester.pumpAndSettle();
expect(_checkBox, false);
_checkBox = true;
await tester.pumpAndSettle();
expect(_checkBox, true);
testWidgets('Testing help icon on bottom navbar',
(WidgetTester tester) async {
await tester.pumpWidget(createWidgetForTesting(child: MainScreen()));
expect(find.byKey(Key('helpIcon')), findsOneWidget);
});
testWidgets('Button selanjutnya', (WidgetTester tester) async {
final buttonSelanjutnya = find.byKey(Key('selanjutnyaButton'));
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(buttonSelanjutnya, findsOneWidget);
expect(find.text("Selanjutnya"), findsOneWidget);
await tester.tap(buttonSelanjutnya);
await tester.pumpAndSettle();
testWidgets('Testing account icon on bottom navbar',
(WidgetTester tester) async {
await tester.pumpWidget(createWidgetForTesting(child: MainScreen()));
expect(find.byKey(Key('accountIcon')), findsOneWidget);
});
testWidgets('Button sebelumnya', (WidgetTester tester) async {
final buttonSebelumnya= find.byKey(Key('sebelumnyaButton'));
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(buttonSebelumnya, findsOneWidget);
expect(find.text("Sebelumnya"), findsOneWidget);
await tester.tap(buttonSebelumnya);
await tester.pumpAndSettle();
});
}
......@@ -14,190 +14,49 @@
// expect(find.byKey(Key('scaffold-base')), findsOneWidget);
// });
// }
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fundex_app/pages/kyc/alamat_body.dart';
import 'package:fundex_app/main-screen.dart';
void main() {
testWidgets('Page mempunyai app bar', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.byIcon(Icons.arrow_back), findsOneWidget);
expect(find.text('e-KYC Pemodal'), findsOneWidget);
});
testWidgets('Terdapat Checkpoint', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.byKey(Key("checkpoint")), findsOneWidget);
expect(find.byKey(Key("line")), findsOneWidget);
});
testWidgets('Terdapat text alamat', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.byKey(Key('teksAlamat')), findsOneWidget);
expect(find.text('Alamat Lengkap Sesuai KTP *'), findsOneWidget);
});
test('Field alamat tidak diisi', () {
var tes = ValidasiAlamat.validate('');
expect(tes, 'Alamat harus di isi');
});
test('Field alamat diisi', () {
var tes = ValidasiAlamat.validate('Jl. Raya gede banget');
expect(tes, null);
});
testWidgets('Terdapat text kode pos', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.text('Kode Pos *'), findsOneWidget);
});
test('Field kode pos tidak diisi', () {
var tes = ValidasiKodePos.validate('');
expect(tes, 'kode pos harus di isi');
});
test('kode pos tidak valid', () {
var tes = ValidasiKodePos.validate('147qwer');
expect(tes, 'kode pos tidak valid');
});
test('Field kode pos diisi', () {
var tes = ValidasiKodePos.validate('1475302');
expect(tes, null);
});
testWidgets('typeAHead berhasil', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.text("Provinsi *"), findsOneWidget);
final typeAHead = find.byKey(Key('typeahead'));
expect(typeAHead, findsOneWidget);
await tester.tap(typeAHead);
await tester.enterText(typeAHead, 'DKI Jakarta');
await tester.tap(typeAHead);
await tester.pump();
expect(find.text('DKI Jakarta'), findsWidgets);
});
test('Field Tempat Lahir tidak diisi', () {
var tes = ValidasiTempat.validate('');
expect(tes, 'Provinsi harus di isi');
});
Widget createWidgetForTesting({Widget child}) {
return MaterialApp(
home: child,
);
}
test('Field Tempat Lahir diisi', () {
var tes = ValidasiTempat.validate('DKI Jakarta');
expect(tes, null);
testWidgets('Testing bottom navigation bar', (WidgetTester tester) async {
await tester.pumpWidget(createWidgetForTesting(child: MainScreen()));
expect(find.byKey(Key('bottomNavigationBar')), findsOneWidget);
});
testWidgets('typeAHead kabupaten berhasil', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.text("Kabupaten / Kota *"), findsOneWidget);
final typeAHead = find.byKey(Key('typeaheadKabupaten'));
expect(typeAHead, findsOneWidget);
await tester.tap(typeAHead);
await tester.enterText(typeAHead, 'Jakarta Timur');
await tester.tap(typeAHead);
await tester.pump();
expect(find.text('Jakarta Timur'), findsWidgets);
testWidgets('Testing home icon on bottom navbar',
(WidgetTester tester) async {
await tester.pumpWidget(createWidgetForTesting(child: MainScreen()));
expect(find.byKey(Key('homeIcon')), findsOneWidget);
});
test('Field Kabupaten tidak diisi', () {
var tes = ValidasiKabupaten.validate('');
expect(tes, 'Kabupaten harus di isi');
testWidgets('Testing portfolio icon on bottom navbar',
(WidgetTester tester) async {
await tester.pumpWidget(createWidgetForTesting(child: MainScreen()));
expect(find.byKey(Key('portfolioIcon')), findsOneWidget);
});
test('Field Kabupaten diisi', () {
var tes = ValidasiKabupaten.validate('Jakarta Timur');
expect(tes, null);
testWidgets('Testing transaction icon on bottom navbar',
(WidgetTester tester) async {
await tester.pumpWidget(createWidgetForTesting(child: MainScreen()));
expect(find.byKey(Key('transactionIcon')), findsOneWidget);
});
testWidgets('typeAHead kecamatan berhasil', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: AlamatBody()));
expect(find.text("Kecamatan *"), findsOneWidget);
final typeAHead = find.byKey(Key('typeaheadKecamatan'));
expect(typeAHead, findsOneWidget);
await tester.tap(typeAHead);
await tester.enterText(typeAHead, 'Ciracas');
await tester.tap(typeAHead);
await tester.pump();
expect(find.text('Ciracas'), findsWidgets);
testWidgets('Testing help icon on bottom navbar',
(WidgetTester tester) async {