Fakultas Ilmu Komputer UI

Commit d5a6948d authored by Michael Wiryadinata Halim's avatar Michael Wiryadinata Halim
Browse files

[REFACTOR] Add test for props

parent 0fc60d0f
Pipeline #52337 passed with stages
in 20 minutes and 57 seconds
......@@ -8,7 +8,10 @@ import 'package:home_industry/Component/router.dart';
import 'package:home_industry/Pages/Transactions/bloc/bloc.dart';
import 'package:home_industry/Pages/Transactions/detail_bloc/bloc.dart';
import 'package:home_industry/Pages/Transactions/detail_bloc/detail_order_bloc.dart';
import 'package:home_industry/Pages/Transactions/model/payment_method.dart';
import 'package:home_industry/Pages/Transactions/model/status.dart';
import 'package:home_industry/Pages/Transactions/model/transaction_entity.dart';
import 'package:home_industry/Pages/Transactions/model/transaction_item_entity.dart';
import 'package:home_industry/Pages/Transactions/my_detail_order.dart';
import 'package:home_industry/Pages/Transactions/repositories/transaction_repository.dart';
import 'package:home_industry/State/Auth/repositories/depedencies_repositories.dart';
......@@ -28,6 +31,56 @@ class MyOrderBlocMock extends MockBloc<MyOrderEvent, MyOrderState>
implements MyOrderBloc {}
void main() {
group("descriotion", () {
Map<String, dynamic> json;
setUp(() async {
json = await parseRawSample('mock/transaction.json');
});
test("Transaction Item", () {
final transaction = Transaction.fromJson(json);
expect(transaction.props, [
'8d0698ac-e90d-4348-8f4a-34126c32df63',
[
TransactionItem(
id: "4dc363fb-9c98-4014-9013-7ad8ed66e51c",
product: "2365e0b2-d7d2-438e-80db-1ca1548442a9",
productCode: "66TNUN",
productName: "LARIIII",
productPrice: "20.00",
quantity: 2),
TransactionItem(
id: "2f369845-8d5e-41b3-9ad3-cf4b5fc1a6ed",
product: "f9560fbf-3020-4194-9a79-a2146c66366a",
productCode: "5MMW2S",
productName: "Nastar Belimbing",
productPrice: "20000.00",
quantity: 7)
],
'GTXWP3PJ',
'140040.00',
'd4b98bb5-8ba4-4a41-af10-93abcf53df58',
'whtestest',
'Michael Wiryadinata halim',
'+628192090199',
'ada deh test',
'002',
'002',
'penggilingan',
'Dummy Sub-District',
'15000.00',
PaymentMethod.transfer,
'Transfer',
'0.00',
StatusTransaction.waitSellerConfirmation,
'Waiting for seller confirmation',
null,
DateTime.parse("2020-04-16 08:04:22.073683Z"),
DateTime.parse("2020-04-17 16:57:16.659287Z"),
'155040.00'
]);
});
});
group("detail order page", () {
Widget widgetTested;
Dio dio;
......@@ -221,6 +274,18 @@ void main() {
"Kecamatan Dummy Sub-District"),
findsOneWidget);
});
testWidgets("loaded 002 tap ubah", (WidgetTester tester) async {
when(detailOrderBloc.state)
.thenAnswer((_) => FetchOrderSuccess(Transaction.fromJson(json)));
await tester.pumpWidget(widgetTested);
expect(find.text("GTXWP3PJ"), findsOneWidget);
expect(find.text("Rp155.040"), findsOneWidget);
expect(find.text("Ubah bukti pembayaran"), findsOneWidget);
await tester.tap(find.text("Ubah bukti pembayaran"));
await tester.pumpAndSettle();
expect(find.text("Pembayaran"), findsOneWidget);
});
});
group("Detail order bloc", () {
......
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