Skip to content

Commit

Permalink
Paywalls: changed total_price_and_per_month to include period (#3044
Browse files Browse the repository at this point in the history
)

From beta feedback. This allows distinguishing subscriptions versus
non-subscriptions.
  • Loading branch information
NachoSoto committed Sep 14, 2023
1 parent ac86cd6 commit 8f17e37
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion RevenueCatUI/Helpers/Package+VariableDataProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extension Package: VariableDataProvider {

func localizedPriceAndPerMonth(_ locale: Locale) -> String {
if !self.isSubscription || self.isMonthly {
return self.localizedPrice
return self.localizedPricePerPeriod(locale)
} else {
let unit = Localization.abbreviatedUnitLocalizedString(for: .month, locale: locale)
return "\(self.localizedPrice) (\(self.localizedPricePerMonth)/\(unit))"
Expand Down
4 changes: 2 additions & 2 deletions Tests/RevenueCatUITests/Data/PackageVariablesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ class PackageVariablesTests: TestCase {

func testEnglishLocalizedPriceAndPerMonth() {
expect(TestData.weeklyPackage.localizedPriceAndPerMonth(Self.english)) == "$1.99 ($7.96/mo)"
expect(TestData.monthlyPackage.localizedPriceAndPerMonth(Self.english)) == "$6.99"
expect(TestData.monthlyPackage.localizedPriceAndPerMonth(Self.english)) == "$6.99/mo"
expect(TestData.annualPackage.localizedPriceAndPerMonth(Self.english)) == "$53.99 ($4.49/mo)"
expect(TestData.lifetimePackage.localizedPriceAndPerMonth(Self.english)) == "$119.49"
}

func testSpanishLocalizedPriceAndPerMonth() {
expect(TestData.weeklyPackage.localizedPriceAndPerMonth(Self.spanish)) == "$1.99 ($7.96/m.)"
expect(TestData.monthlyPackage.localizedPriceAndPerMonth(Self.spanish)) == "$6.99"
expect(TestData.monthlyPackage.localizedPriceAndPerMonth(Self.spanish)) == "$6.99/m."
expect(TestData.annualPackage.localizedPriceAndPerMonth(Self.spanish)) == "$53.99 ($4.49/m.)"
expect(TestData.lifetimePackage.localizedPriceAndPerMonth(Self.spanish)) == "$119.49"
}
Expand Down
10 changes: 9 additions & 1 deletion Tests/RevenueCatUITests/Data/VariablesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ class VariablesTests: TestCase {
expect(result) == "$119.49"
}

func testTotalPriceAndPerMonthForForMonthlyPackage() {
let result = VariableHandler.processVariables(
in: "{{ total_price_and_per_month }}",
with: TestData.monthlyPackage
)
expect(result) == "$6.99/mo"
}

func testTotalPriceAndPerMonthForCustomMonthlyProductsReturnsPrice() {
let result = VariableHandler.processVariables(
in: "{{ total_price_and_per_month }}",
Expand All @@ -153,7 +161,7 @@ class VariablesTests: TestCase {
offeringIdentifier: ""
)
)
expect(result) == "$6.99"
expect(result) == "$6.99/mo"
}

func testTotalPriceAndPerMonthForCustomAnnualProductsReturnsPriceAndPerMonth() {
Expand Down

0 comments on commit 8f17e37

Please sign in to comment.