From 4f5d03b29b9ee0b9b85c51d87c2727d4cfcffd46 Mon Sep 17 00:00:00 2001 From: Toni Rico Date: Mon, 16 Sep 2024 17:36:28 +0200 Subject: [PATCH] Fix tests --- .../Data/PackageVariablesTests.swift | 40 +++++++++---------- .../Data/VariablesTests.swift | 2 +- .../StoreKitUnitTests/StoreProductTests.swift | 2 +- .../SubscriptionPeriodTests.swift | 21 +++++----- 4 files changed, 34 insertions(+), 31 deletions(-) diff --git a/Tests/RevenueCatUITests/Data/PackageVariablesTests.swift b/Tests/RevenueCatUITests/Data/PackageVariablesTests.swift index 31b318bcca..d39f2ca857 100644 --- a/Tests/RevenueCatUITests/Data/PackageVariablesTests.swift +++ b/Tests/RevenueCatUITests/Data/PackageVariablesTests.swift @@ -34,19 +34,19 @@ class PackageVariablesTests: TestCase { func testLocalizedPricePerWeek() { expect(TestData.weeklyPackage.localizedPricePerWeek()) == "$1.99" - expect(TestData.monthlyPackage.localizedPricePerWeek()) == "$1.60" + expect(TestData.monthlyPackage.localizedPricePerWeek()) == "$1.61" expect(TestData.threeMonthPackage.localizedPricePerWeek()) == "$0.38" - expect(TestData.sixMonthPackage.localizedPricePerWeek()) == "$0.30" - expect(TestData.annualPackage.localizedPricePerWeek()) == "$1.03" + expect(TestData.sixMonthPackage.localizedPricePerWeek()) == "$0.31" + expect(TestData.annualPackage.localizedPricePerWeek()) == "$1.04" expect(TestData.lifetimePackage.localizedPricePerWeek()) == "$119.49" } func testLocalizedPricePerMonth() { - expect(TestData.weeklyPackage.localizedPricePerMonth()) == "$8.64" + expect(TestData.weeklyPackage.localizedPricePerMonth()) == "$8.65" expect(TestData.monthlyPackage.localizedPricePerMonth()) == "$6.99" expect(TestData.threeMonthPackage.localizedPricePerMonth()) == "$1.66" expect(TestData.sixMonthPackage.localizedPricePerMonth()) == "$1.33" - expect(TestData.annualPackage.localizedPricePerMonth()) == "$4.49" + expect(TestData.annualPackage.localizedPricePerMonth()) == "$4.50" expect(TestData.lifetimePackage.localizedPricePerMonth()) == "$119.49" } @@ -104,20 +104,20 @@ class PackageVariablesTests: TestCase { } func testEnglishLocalizedPriceAndPerMonth() { - expect(TestData.weeklyPackage.localizedPriceAndPerMonth(Self.english)) == "$1.99/wk ($8.64/mo)" + expect(TestData.weeklyPackage.localizedPriceAndPerMonth(Self.english)) == "$1.99/wk ($8.65/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)" - expect(TestData.annualPackage.localizedPriceAndPerMonth(Self.english)) == "$53.99/yr ($4.49/mo)" + expect(TestData.annualPackage.localizedPriceAndPerMonth(Self.english)) == "$53.99/yr ($4.50/mo)" expect(TestData.lifetimePackage.localizedPriceAndPerMonth(Self.english)) == "$119.49" } func testSpanishLocalizedPriceAndPerMonth() { - expect(TestData.weeklyPackage.localizedPriceAndPerMonth(Self.spanish)) == "$1.99/sem ($8.64/m.)" + expect(TestData.weeklyPackage.localizedPriceAndPerMonth(Self.spanish)) == "$1.99/sem ($8.65/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.)" - expect(TestData.annualPackage.localizedPriceAndPerMonth(Self.spanish)) == "$53.99/año ($4.49/m.)" + expect(TestData.annualPackage.localizedPriceAndPerMonth(Self.spanish)) == "$53.99/año ($4.50/m.)" expect(TestData.lifetimePackage.localizedPriceAndPerMonth(Self.spanish)) == "$119.49" } @@ -125,7 +125,7 @@ class PackageVariablesTests: TestCase { let arabicPrice = "٣.٩٩ درهم" expect(TestData.weeklyPackage.with(arabicPrice, Self.arabic).localizedPriceAndPerMonth(Self.arabic)) - .to(equalIgnoringRTL("٣.٩٩ درهم/أسبوع (‏8.64 ‏د.إ.‏/شهر)")) + .to(equalIgnoringRTL("٣.٩٩ درهم/أسبوع (‏8.65 ‏د.إ.‏/شهر)")) expect(TestData.monthlyPackage.with(arabicPrice, Self.arabic).localizedPriceAndPerMonth(Self.arabic)) .to(equalIgnoringRTL("٣.٩٩ درهم/شهر")) expect(TestData.threeMonthPackage.with(arabicPrice, Self.arabic).localizedPriceAndPerMonth(Self.arabic)) @@ -133,26 +133,26 @@ class PackageVariablesTests: TestCase { expect(TestData.sixMonthPackage.with(arabicPrice, Self.arabic).localizedPriceAndPerMonth(Self.arabic)) .to(equalIgnoringRTL("٣.٩٩ درهم/6شهر (‏1.33 ‏د.إ.‏/شهر)")) expect(TestData.annualPackage.with(arabicPrice, Self.arabic).localizedPriceAndPerMonth(Self.arabic)) - .to(equalIgnoringRTL("٣.٩٩ درهم/سنة (‏4.49 ‏د.إ.‏/شهر)")) + .to(equalIgnoringRTL("٣.٩٩ درهم/سنة (‏4.50 ‏د.إ.‏/شهر)")) expect(TestData.lifetimePackage.with(arabicPrice, Self.arabic).localizedPriceAndPerMonth(Self.arabic)) == arabicPrice } func testEnglishLocalizedPriceAndPerMonthFull() { - expect(TestData.weeklyPackage.localizedPriceAndPerMonthFull(Self.english)) == "$1.99/week ($8.64/month)" + expect(TestData.weeklyPackage.localizedPriceAndPerMonthFull(Self.english)) == "$1.99/week ($8.65/month)" expect(TestData.monthlyPackage.localizedPriceAndPerMonthFull(Self.english)) == "$6.99/month" expect(TestData.threeMonthPackage.localizedPriceAndPerMonthFull(Self.english)) == "$4.99/3months ($1.66/month)" expect(TestData.sixMonthPackage.localizedPriceAndPerMonthFull(Self.english)) == "$7.99/6months ($1.33/month)" - expect(TestData.annualPackage.localizedPriceAndPerMonthFull(Self.english)) == "$53.99/year ($4.49/month)" + expect(TestData.annualPackage.localizedPriceAndPerMonthFull(Self.english)) == "$53.99/year ($4.50/month)" expect(TestData.lifetimePackage.localizedPriceAndPerMonthFull(Self.english)) == "$119.49" } func testSpanishLocalizedPriceAndPerMonthFull() { - expect(TestData.weeklyPackage.localizedPriceAndPerMonthFull(Self.spanish)) == "$1.99/semana ($8.64/mes)" + expect(TestData.weeklyPackage.localizedPriceAndPerMonthFull(Self.spanish)) == "$1.99/semana ($8.65/mes)" expect(TestData.monthlyPackage.localizedPriceAndPerMonthFull(Self.spanish)) == "$6.99/mes" expect(TestData.threeMonthPackage.localizedPriceAndPerMonthFull(Self.spanish)) == "$4.99/3meses ($1.66/mes)" expect(TestData.sixMonthPackage.localizedPriceAndPerMonthFull(Self.spanish)) == "$7.99/6meses ($1.33/mes)" - expect(TestData.annualPackage.localizedPriceAndPerMonthFull(Self.spanish)) == "$53.99/año ($4.49/mes)" + expect(TestData.annualPackage.localizedPriceAndPerMonthFull(Self.spanish)) == "$53.99/año ($4.50/mes)" expect(TestData.lifetimePackage.localizedPriceAndPerMonthFull(Self.spanish)) == "$119.49" } @@ -312,7 +312,7 @@ class PackageVariablesTests: TestCase { expect(TestData .annualPackage .localizedPriceAndPerMonthFull(Self.english, - showZeroDecimalPlacePrices: true)) == "$53.99/year ($4.49/month)" + showZeroDecimalPlacePrices: true)) == "$53.99/year ($4.50/month)" expect(TestData .annualPackage60Taiwan @@ -322,12 +322,12 @@ class PackageVariablesTests: TestCase { expect(TestData .threeMonthPackageThailand .localizedPriceAndPerMonthFull(Locale.taiwan, - showZeroDecimalPlacePrices: true)) == "฿5/3個月 (฿1.66/個月)" + showZeroDecimalPlacePrices: true)) == "฿5/3個月 (฿1.67/個月)" expect(TestData .threeMonthPackageThailand .localizedPriceAndPerMonthFull(Locale.thailand, - showZeroDecimalPlacePrices: true)) == "฿5/3เดือน (฿1.66/เดือน)" + showZeroDecimalPlacePrices: true)) == "฿5/3เดือน (฿1.67/เดือน)" // test rounding off expect(TestData @@ -342,7 +342,7 @@ class PackageVariablesTests: TestCase { expect(TestData .annualPackage .localizedPriceAndPerMonthFull(Self.english, - showZeroDecimalPlacePrices: false)) == "$53.99/year ($4.49/month)" + showZeroDecimalPlacePrices: false)) == "$53.99/year ($4.50/month)" expect(TestData .annualPackage60Taiwan @@ -352,7 +352,7 @@ class PackageVariablesTests: TestCase { expect(TestData .threeMonthPackageThailand .localizedPriceAndPerMonthFull(Locale.thailand, - showZeroDecimalPlacePrices: false)) == "฿5.00/3เดือน (฿1.66/เดือน)" + showZeroDecimalPlacePrices: false)) == "฿5.00/3เดือน (฿1.67/เดือน)" } diff --git a/Tests/RevenueCatUITests/Data/VariablesTests.swift b/Tests/RevenueCatUITests/Data/VariablesTests.swift index 92c7f083a3..6a598522fc 100644 --- a/Tests/RevenueCatUITests/Data/VariablesTests.swift +++ b/Tests/RevenueCatUITests/Data/VariablesTests.swift @@ -233,7 +233,7 @@ class VariablesTests: TestCase { offeringIdentifier: "" ) ) - expect(result) == "$53.99/yr ($4.49/mo)" + expect(result) == "$53.99/yr ($4.50/mo)" } func testRelativeDiscountWithNoDiscount() { diff --git a/Tests/StoreKitUnitTests/StoreProductTests.swift b/Tests/StoreKitUnitTests/StoreProductTests.swift index 3244295980..1b0cbff25f 100644 --- a/Tests/StoreKitUnitTests/StoreProductTests.swift +++ b/Tests/StoreKitUnitTests/StoreProductTests.swift @@ -446,7 +446,7 @@ class StoreProductTests: StoreKitConfigTestCase { let sk1Fetcher = ProductsFetcherSK1(requestTimeout: Configuration.storeKitRequestTimeoutDefault) let storeProduct = try await sk1Fetcher.product(withIdentifier: Self.productID) - expect(storeProduct.localizedPricePerWeek) == "$1.14" + expect(storeProduct.localizedPricePerWeek) == "$1.15" expect(storeProduct.localizedPricePerMonth) == "$4.99" expect(storeProduct.localizedPricePerYear) == "$59.88" } diff --git a/Tests/UnitTests/Purchasing/StoreKitAbstractions/SubscriptionPeriodTests.swift b/Tests/UnitTests/Purchasing/StoreKitAbstractions/SubscriptionPeriodTests.swift index bbb96338d9..5da1d985fa 100644 --- a/Tests/UnitTests/Purchasing/StoreKitAbstractions/SubscriptionPeriodTests.swift +++ b/Tests/UnitTests/Purchasing/StoreKitAbstractions/SubscriptionPeriodTests.swift @@ -51,12 +51,13 @@ 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.44), + .init(p(1, .month), 14.99, 3.45), + .init(p(1, .month), 14.9899999999, 3.45), .init(p(2, .month), 30, 3.45), - .init(p(3, .month), 40, 3.06), + .init(p(3, .month), 40, 3.07), .init(p(1, .year), 120, 2.3), - .init(p(1, .year), 50, 0.95), - .init(p(1, .year), 29.99, 0.57), + .init(p(1, .year), 50, 0.96), + .init(p(1, .year), 29.99, 0.58), .init(p(3, .year), 720, 4.6) ] @@ -78,13 +79,14 @@ class SubscriptionPeriodTests: TestCase { .init(p(1, .day), 2, 60), .init(p(15, .day), 5, 10), .init(p(1, .week), 10, 43.45), - .init(p(2, .week), 10, 21.72), + .init(p(2, .week), 10, 21.73), .init(p(1, .month), 14.99, 14.99), + .init(p(1, .month), 14.9899999999, 14.99), .init(p(2, .month), 30, 15), .init(p(3, .month), 40, 13.33), .init(p(1, .year), 120, 10), - .init(p(1, .year), 50, 4.16), - .init(p(1, .year), 29.99, 2.49), + .init(p(1, .year), 50, 4.17), + .init(p(1, .year), 29.99, 2.5), .init(p(3, .year), 720, 20) ] @@ -105,10 +107,11 @@ class SubscriptionPeriodTests: TestCase { let tests: [Test] = [ .init(p(1, .day), 1, 365), .init(p(1, .day), 2, 730), - .init(p(15, .day), 5, 121.66), - .init(p(1, .week), 10, 521.42), + .init(p(15, .day), 5, 121.67), + .init(p(1, .week), 10, 521.43), .init(p(2, .week), 10, 260.71), .init(p(1, .month), 14.99, 179.88), + .init(p(1, .month), 14.9899999999, 179.88), .init(p(1, .month), 5, 60), .init(p(2, .month), 30, 180), .init(p(3, .month), 40, 160),