From 767181e9e4199c059fb1c50c63e140fc2804c65c Mon Sep 17 00:00:00 2001 From: Alexander Zhdanov Date: Fri, 21 May 2021 21:00:57 +0500 Subject: [PATCH] [in_app_purchase] add test for InAppPurchase.buyConsumable --- .../test/in_app_purchase_test.dart | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase/test/in_app_purchase_test.dart b/packages/in_app_purchase/in_app_purchase/test/in_app_purchase_test.dart index 494c3145c51d..b8c7bd89206b 100644 --- a/packages/in_app_purchase/in_app_purchase/test/in_app_purchase_test.dart +++ b/packages/in_app_purchase/in_app_purchase/test/in_app_purchase_test.dart @@ -87,15 +87,33 @@ void main() { }); test('buyConsumable', () async { + final purchaseParam = PurchaseParam(productDetails: productDetails); final bool result = await inAppPurchase.buyConsumable( - purchaseParam: PurchaseParam( - productDetails: productDetails, - ), + purchaseParam: purchaseParam, + ); + + expect(result, true); + expect(fakePlatform.log, [ + isMethodCall('buyConsumable', arguments: { + "purchaseParam": purchaseParam, + "autoConsume": true, + }), + ]); + }); + + test('buyConsumable with autoConsume=false', () async { + final purchaseParam = PurchaseParam(productDetails: productDetails); + final bool result = await inAppPurchase.buyConsumable( + purchaseParam: purchaseParam, + autoConsume: false, ); expect(result, true); expect(fakePlatform.log, [ - isMethodCall('buyConsumable', arguments: null), + isMethodCall('buyConsumable', arguments: { + "purchaseParam": purchaseParam, + "autoConsume": false, + }), ]); }); @@ -152,7 +170,10 @@ class MockInAppPurchasePlatform extends Fake required PurchaseParam purchaseParam, bool autoConsume = true, }) { - log.add(MethodCall('buyConsumable')); + log.add(MethodCall('buyConsumable', { + "purchaseParam": purchaseParam, + "autoConsume": autoConsume, + })); return Future.value(true); }