Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
[in_app_purchase] add test for InAppPurchase.buyConsumable
Browse files Browse the repository at this point in the history
  • Loading branch information
qwert2603 committed May 21, 2021
1 parent 1cd7082 commit 767181e
Showing 1 changed file with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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, <Matcher>[
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, <Matcher>[
isMethodCall('buyConsumable', arguments: null),
isMethodCall('buyConsumable', arguments: {
"purchaseParam": purchaseParam,
"autoConsume": false,
}),
]);
});

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 767181e

Please sign in to comment.