From 6a28a5233d0a4b3f1c527de560e3372ff537c2b0 Mon Sep 17 00:00:00 2001 From: Andy Boedo Date: Wed, 29 Nov 2023 14:47:41 -0300 Subject: [PATCH 1/2] updated the price per month calculations to be more accurate, with weeks per month being 4.345 instead of 4.0 --- .../StoreKitAbstractions/SubscriptionPeriod.swift | 2 +- .../StoreKitAbstractions/SubscriptionPeriodTests.swift | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/Purchasing/StoreKitAbstractions/SubscriptionPeriod.swift b/Sources/Purchasing/StoreKitAbstractions/SubscriptionPeriod.swift index a0cb168070..f98e681b38 100644 --- a/Sources/Purchasing/StoreKitAbstractions/SubscriptionPeriod.swift +++ b/Sources/Purchasing/StoreKitAbstractions/SubscriptionPeriod.swift @@ -167,7 +167,7 @@ private extension SubscriptionPeriod { static let daysPerWeek: Decimal = 7 static let daysPerMonth: Decimal = 30 static let daysPerYear: Decimal = 365 - static let weeksPerMonth: Decimal = 4 + static let weeksPerMonth: Decimal = daysPerYear / monthsPerYear / daysPerWeek static let weeksPerYear: Decimal = 52.14 static let monthsPerYear: Decimal = 12 } diff --git a/Tests/UnitTests/Purchasing/StoreKitAbstractions/SubscriptionPeriodTests.swift b/Tests/UnitTests/Purchasing/StoreKitAbstractions/SubscriptionPeriodTests.swift index 628422eb99..3b625057c2 100644 --- a/Tests/UnitTests/Purchasing/StoreKitAbstractions/SubscriptionPeriodTests.swift +++ b/Tests/UnitTests/Purchasing/StoreKitAbstractions/SubscriptionPeriodTests.swift @@ -51,9 +51,9 @@ class SubscriptionPeriodTests: TestCase { .init(p(14, .day), 2, 1), .init(p(1, .week), 10, 10), .init(p(2, .week), 10, 5), - .init(p(1, .month), 14.99, 3.74), - .init(p(2, .month), 30, 3.75), - .init(p(3, .month), 40, 3.33), + .init(p(1, .month), 14.99, 3.44), + .init(p(2, .month), 30, 3.45), + .init(p(3, .month), 40, 3.06), .init(p(1, .year), 120, 2.3), .init(p(1, .year), 50, 0.95), .init(p(1, .year), 29.99, 0.57), @@ -77,8 +77,8 @@ class SubscriptionPeriodTests: TestCase { let tests: [Test] = [ .init(p(1, .day), 2, 60), .init(p(15, .day), 5, 10), - .init(p(1, .week), 10, 40), - .init(p(2, .week), 10, 20), + .init(p(1, .week), 10, 43.45), + .init(p(2, .week), 10, 21.72), .init(p(1, .month), 14.99, 14.99), .init(p(2, .month), 30, 15), .init(p(3, .month), 40, 13.33), From 5c19ab27846ac9db80fbf48a168f3eba7a280630 Mon Sep 17 00:00:00 2001 From: Andy Boedo Date: Wed, 29 Nov 2023 16:26:10 -0300 Subject: [PATCH 2/2] updated tests in a few more places --- .../Data/PackageVariablesTests.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Tests/RevenueCatUITests/Data/PackageVariablesTests.swift b/Tests/RevenueCatUITests/Data/PackageVariablesTests.swift index c15bd4dda6..c0111a5bf9 100644 --- a/Tests/RevenueCatUITests/Data/PackageVariablesTests.swift +++ b/Tests/RevenueCatUITests/Data/PackageVariablesTests.swift @@ -32,15 +32,15 @@ class PackageVariablesTests: TestCase { func testLocalizedPricePerWeek() { expect(TestData.weeklyPackage.localizedPricePerWeek) == "$1.99" - expect(TestData.monthlyPackage.localizedPricePerWeek) == "$1.74" - expect(TestData.threeMonthPackage.localizedPricePerWeek) == "$0.41" - expect(TestData.sixMonthPackage.localizedPricePerWeek) == "$0.33" + expect(TestData.monthlyPackage.localizedPricePerWeek) == "$1.60" + expect(TestData.threeMonthPackage.localizedPricePerWeek) == "$0.38" + expect(TestData.sixMonthPackage.localizedPricePerWeek) == "$0.30" expect(TestData.annualPackage.localizedPricePerWeek) == "$1.03" expect(TestData.lifetimePackage.localizedPricePerWeek) == "$119.49" } func testLocalizedPricePerMonth() { - expect(TestData.weeklyPackage.localizedPricePerMonth) == "$7.96" + expect(TestData.weeklyPackage.localizedPricePerMonth) == "$8.64" expect(TestData.monthlyPackage.localizedPricePerMonth) == "$6.99" expect(TestData.threeMonthPackage.localizedPricePerMonth) == "$1.66" expect(TestData.sixMonthPackage.localizedPricePerMonth) == "$1.33" @@ -84,7 +84,7 @@ class PackageVariablesTests: TestCase { } func testEnglishLocalizedPriceAndPerMonth() { - expect(TestData.weeklyPackage.localizedPriceAndPerMonth(Self.english)) == "$1.99/wk ($7.96/mo)" + expect(TestData.weeklyPackage.localizedPriceAndPerMonth(Self.english)) == "$1.99/wk ($8.64/mo)" expect(TestData.monthlyPackage.localizedPriceAndPerMonth(Self.english)) == "$6.99/mo" expect(TestData.threeMonthPackage.localizedPriceAndPerMonth(Self.english)) == "$4.99/3mo ($1.66/mo)" expect(TestData.sixMonthPackage.localizedPriceAndPerMonth(Self.english)) == "$7.99/6mo ($1.33/mo)" @@ -93,7 +93,7 @@ class PackageVariablesTests: TestCase { } func testSpanishLocalizedPriceAndPerMonth() { - expect(TestData.weeklyPackage.localizedPriceAndPerMonth(Self.spanish)) == "$1.99/sem ($7.96/m.)" + expect(TestData.weeklyPackage.localizedPriceAndPerMonth(Self.spanish)) == "$1.99/sem ($8.64/m.)" expect(TestData.monthlyPackage.localizedPriceAndPerMonth(Self.spanish)) == "$6.99/m." expect(TestData.threeMonthPackage.localizedPriceAndPerMonth(Self.spanish)) == "$4.99/3m ($1.66/m.)" expect(TestData.sixMonthPackage.localizedPriceAndPerMonth(Self.spanish)) == "$7.99/6m ($1.33/m.)" @@ -105,7 +105,7 @@ class PackageVariablesTests: TestCase { let arabicPrice = "٣.٩٩ درهم" expect(TestData.weeklyPackage.with(arabicPrice, Self.arabic).localizedPriceAndPerMonth(Self.arabic)) - .to(equalIgnoringRTL("٣.٩٩ درهم/أسبوع (‏7.96 ‏د.إ.‏/شهر)")) + .to(equalIgnoringRTL("٣.٩٩ درهم/أسبوع (‏8.64 ‏د.إ.‏/شهر)")) expect(TestData.monthlyPackage.with(arabicPrice, Self.arabic).localizedPriceAndPerMonth(Self.arabic)) .to(equalIgnoringRTL("٣.٩٩ درهم/شهر")) expect(TestData.threeMonthPackage.with(arabicPrice, Self.arabic).localizedPriceAndPerMonth(Self.arabic))