-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[in_app_purchase] Added currency code and numerical price to product detail model. #3794
Changes from 8 commits
8387519
f2b38bc
dbf2793
fb66616
89f8df5
c210e54
e48fbc2
28d2518
277b96b
9cefe81
5e49a4f
194948d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:in_app_purchase/in_app_purchase.dart'; | ||
import 'package:in_app_purchase/src/store_kit_wrappers/sk_product_wrapper.dart'; | ||
|
||
void main() { | ||
group('Constructor Tests', () { | ||
test('fromSkProduct should correctly parse the price data', () { | ||
final SKProductWrapper dummyProductWrapper = SKProductWrapper( | ||
productIdentifier: 'id', | ||
localizedTitle: 'title', | ||
localizedDescription: 'description', | ||
priceLocale: | ||
SKPriceLocaleWrapper(currencySymbol: '\$', currencyCode: 'USD'), | ||
subscriptionGroupIdentifier: 'com.group', | ||
price: '13.37', | ||
); | ||
|
||
ProductDetails productDetails = | ||
ProductDetails.fromSKProduct(dummyProductWrapper); | ||
expect(productDetails.rawPrice, equals(13.37)); | ||
}); | ||
|
||
test('fromSkuDetails should correctly parse the price data', () { | ||
final SkuDetailsWrapper dummyDetailWrapper = SkuDetailsWrapper( | ||
description: 'description', | ||
freeTrialPeriod: 'freeTrialPeriod', | ||
introductoryPrice: 'introductoryPrice', | ||
introductoryPriceMicros: 'introductoryPriceMicros', | ||
introductoryPriceCycles: 1, | ||
introductoryPricePeriod: 'introductoryPricePeriod', | ||
price: '13.37', | ||
priceAmountMicros: 13370000, | ||
priceCurrencyCode: 'usd', | ||
sku: 'sku', | ||
subscriptionPeriod: 'subscriptionPeriod', | ||
title: 'title', | ||
type: SkuType.inapp, | ||
originalPrice: 'originalPrice', | ||
originalPriceAmountMicros: 1000, | ||
); | ||
|
||
ProductDetails productDetails = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should also test productDetails.currencyCode There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main reason I only decided to test the I can of course also test I'm curious if you have any thoughts on this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ideally, if we can, it would be nice to test all the properties being set with the constructor. It would be awesome if you could add those in this PR! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure thing! The changes have been added. |
||
ProductDetails.fromSkuDetails(dummyDetailWrapper); | ||
expect(productDetails.rawPrice, equals(13.37)); | ||
}); | ||
}); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.