Fakultas Ilmu Komputer UI

Commit 0d106b71 authored by Tsamara Esperanti Erwin's avatar Tsamara Esperanti Erwin 🦄
Browse files

Merge branch 'coldfix-pbi4' into 'staging'

Coldfix pbi4

See merge request !86
parents 56be4b20 405e3712
Pipeline #60692 passed with stages
in 27 minutes and 30 seconds
......@@ -20,6 +20,7 @@ class GoodsDonationBloc extends Bloc<GoodsDonationEvent, GoodsDonationState> {
Stream<GoodsDonationState> mapEventToState(GoodsDonationEvent event) async* {
if (event is GoodsDonationButtonClicked) {
yield const SendingGoodsDonationLoading();
print(event.isFinal);
try {
await _donationRepository.createGoodsDonation(
event.program,
......@@ -27,10 +28,11 @@ class GoodsDonationBloc extends Bloc<GoodsDonationEvent, GoodsDonationState> {
event.description,
event.address,
event.methodOfDelivery);
_changeBottomNavigationBarBloc.add(const DonationOccur());
yield const SendingGoodsDonationSuccess();
if (event.isFinal) {
_changeBottomNavigationBarBloc.add(const DonationOccur());
yield const SendingGoodsDonationSuccess();
}
} on DioError catch (_) {
print(_.response);
yield const SendingGoodsDonationError();
}
}
......
......@@ -11,12 +11,14 @@ class GoodsDonationButtonClicked extends GoodsDonationEvent {
final String description;
final String address;
final String methodOfDelivery;
final bool isFinal;
const GoodsDonationButtonClicked(
{@required this.program,
@required this.quantity,
@required this.description,
@required this.methodOfDelivery,
@required this.isFinal,
this.address});
@override
List<Object> get props =>
......
This diff is collapsed.
......@@ -41,15 +41,23 @@ void main() {
});
test('Goods donation event props test', () {
const initialGoodsDonation = InitialGoodsDonationState();
expect(initialGoodsDonation.props, []);
const sendingGoodsDonationError = SendingGoodsDonationError();
expect(sendingGoodsDonationError.props, []);
const program = donationCreate;
const quantity = '2';
const description = 'description';
const address = 'rumahku';
const isFinal = true;
const goodsDonationButtonClicked = GoodsDonationButtonClicked(program: donationCreate,
quantity: quantity,
description: description,
address: address,
methodOfDelivery: 'PCK');
methodOfDelivery: 'PCK',
isFinal: isFinal);
expect(goodsDonationButtonClicked.props, [program, quantity, description, address]);
});
......@@ -65,12 +73,12 @@ void main() {
quantity: '2',
description: 'ini barang',
address: 'null',
methodOfDelivery: 'PCK'
methodOfDelivery: 'PCK',
isFinal: false
)),
expect: [SendingGoodsDonationLoading(), SendingGoodsDonationSuccess()],
expect: [SendingGoodsDonationLoading()],
verify: (_) async {
verify(dio.post(donationCreate, data: anyNamed('data'))).called(1);
verify(changeBottomNavigationBarBloc.add(DonationOccur()));
});
blocTest('Goods Donation Pick Up Success',
......@@ -85,7 +93,8 @@ void main() {
quantity: '2',
description: 'ini barang',
address: 'null',
methodOfDelivery: 'DLV'
methodOfDelivery: 'DLV',
isFinal: true
)),
expect: [SendingGoodsDonationLoading(), SendingGoodsDonationSuccess()],
verify: (_) async {
......@@ -133,6 +142,28 @@ void main() {
expect(find.byType(Form), findsOneWidget);
expect(find.byType(TextFormField), findsNWidgets(2));
expect(find.text('DONASI SEKARANG'), findsOneWidget);
await tester.tap(find.text('DONASI SEKARANG'));
await tester.pump(Duration(seconds: 5));
expect(find.text('Mohon isi jenis barang'), findsOneWidget);
expect(find.text('Mohon isi jumlah barang'), findsOneWidget);
expect(find.text('Mohon pilih metode pengiriman'), findsOneWidget);
await tester.tap(find.byKey(Key('PCK-button')));
await tester.pump(Duration(seconds: 5));
expect(find.byType(TextFormField), findsNWidgets(3));
await tester.tap(find.byKey(Key('addRemoveButton0')));
await tester.pump(Duration(seconds: 5));
expect(find.byType(TextFormField), findsNWidgets(5));
await tester.tap(find.byKey(Key('addRemoveButton0')));
await tester.pump(Duration(seconds: 5));
expect(find.byType(TextFormField), findsNWidgets(3));
await tester.tap(find.byKey(Key('DLV-button')));
await tester.pump(Duration(seconds: 5));
expect(find.byType(TextFormField), findsNWidgets(2));
});
});
}
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