Skip to content

Commit

Permalink
Fix PaywallsTester by changing TestData DEBUG checks (#4092)
Browse files Browse the repository at this point in the history
Round 2 on #4087. There
were still some stuff not being available to `PaywallsTester` on archive
  • Loading branch information
vegaro authored Jul 19, 2024
1 parent 0de331f commit fb7ea42
Showing 1 changed file with 45 additions and 46 deletions.
91 changes: 45 additions & 46 deletions RevenueCatUI/Data/TestData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ enum TestData {
)
}()

#if DEBUG

static let weeklyProduct = TestStoreProduct(
localizedTitle: "Weekly",
price: 1.99,
Expand Down Expand Up @@ -116,40 +114,6 @@ enum TestData {
subscriptionPeriod: nil,
locale: Self.locale
)
static let productWithIntroOffer = TestStoreProduct(
localizedTitle: "PRO monthly",
price: 3.99,
localizedPriceString: "$3.99",
productIdentifier: "com.revenuecat.product_4",
productType: .autoRenewableSubscription,
localizedDescription: "PRO monthly",
subscriptionGroupIdentifier: "group",
subscriptionPeriod: .init(value: 1, unit: .month),
introductoryDiscount: .init(
identifier: "intro",
price: 0,
localizedPriceString: "$0.00",
paymentMode: .freeTrial,
subscriptionPeriod: .init(value: 1, unit: .week),
numberOfPeriods: 1,
type: .introductory
),
discounts: [],
locale: Self.locale
)
static let productWithNoIntroOffer = TestStoreProduct(
localizedTitle: "PRO annual",
price: 34.99,
localizedPriceString: "$34.99",
productIdentifier: "com.revenuecat.product_3",
productType: .autoRenewableSubscription,
localizedDescription: "PRO annual",
subscriptionGroupIdentifier: "group",
subscriptionPeriod: .init(value: 1, unit: .year),
introductoryDiscount: nil,
discounts: [],
locale: Self.locale
)
// @PublicForExternalTesting
static let weeklyPackage = Package(
identifier: PackageType.weekly.identifier,
Expand Down Expand Up @@ -185,6 +149,49 @@ enum TestData {
storeProduct: Self.annualProduct.toStoreProduct(),
offeringIdentifier: Self.offeringIdentifier
)
// @PublicForExternalTesting
static let lifetimePackage = Package(
identifier: PackageType.lifetime.identifier,
packageType: .lifetime,
storeProduct: Self.lifetimeProduct.toStoreProduct(),
offeringIdentifier: Self.offeringIdentifier
)

#if DEBUG
static let productWithIntroOffer = TestStoreProduct(
localizedTitle: "PRO monthly",
price: 3.99,
localizedPriceString: "$3.99",
productIdentifier: "com.revenuecat.product_4",
productType: .autoRenewableSubscription,
localizedDescription: "PRO monthly",
subscriptionGroupIdentifier: "group",
subscriptionPeriod: .init(value: 1, unit: .month),
introductoryDiscount: .init(
identifier: "intro",
price: 0,
localizedPriceString: "$0.00",
paymentMode: .freeTrial,
subscriptionPeriod: .init(value: 1, unit: .week),
numberOfPeriods: 1,
type: .introductory
),
discounts: [],
locale: Self.locale
)
static let productWithNoIntroOffer = TestStoreProduct(
localizedTitle: "PRO annual",
price: 34.99,
localizedPriceString: "$34.99",
productIdentifier: "com.revenuecat.product_3",
productType: .autoRenewableSubscription,
localizedDescription: "PRO annual",
subscriptionGroupIdentifier: "group",
subscriptionPeriod: .init(value: 1, unit: .year),
introductoryDiscount: nil,
discounts: [],
locale: Self.locale
)
static let customPackage = Package(
identifier: "Custom",
packageType: .custom,
Expand All @@ -211,14 +218,6 @@ enum TestData {
storeProduct: productWithNoIntroOffer.toStoreProduct(),
offeringIdentifier: Self.offeringIdentifier
)
// @PublicForExternalTesting
static let lifetimePackage = Package(
identifier: PackageType.lifetime.identifier,
packageType: .lifetime,
storeProduct: Self.lifetimeProduct.toStoreProduct(),
offeringIdentifier: Self.offeringIdentifier
)

static let packages = [
Self.packageWithIntroOffer,
Self.packageWithNoIntroOffer
Expand Down Expand Up @@ -729,6 +728,8 @@ enum TestData {
)
static let paywallAssetBaseURL = URL(string: "https://assets.pawwalls.com")!

#endif

#if os(watchOS)
// `Locale.current` in watchOS produces `en_001` when running tests
static let locale: Locale = .init(identifier: "en_US")
Expand All @@ -754,8 +755,6 @@ enum TestData {
)
}

#endif

}

// MARK: -
Expand Down

0 comments on commit fb7ea42

Please sign in to comment.