-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Paywalls
: fix finding locales with different regions
#3633
Changes from all commits
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 |
---|---|---|
|
@@ -122,6 +122,38 @@ class PaywallDataTests: BaseHTTPResponseTest { | |
expect(esConfig.title) == "Tienda" | ||
} | ||
|
||
func testLocalizedConfigurationFallsBackToLanguageWithDifferentRegion() throws { | ||
let paywall: PaywallData = try self.decodeFixture("PaywallData-Sample1") | ||
|
||
let enConfig = try XCTUnwrap(paywall.localizedConfiguration(for: [ | ||
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. And also have a test for this method, which we didn't have before. |
||
.init(identifier: "en_IN"), | ||
.init(identifier: "en-IN"), | ||
.init(identifier: "en-IN").removingRegion | ||
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 fact that this is included in |
||
].compactMap { $0 })) | ||
expect(enConfig.title) == "Paywall" | ||
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. This was a failing test before the fix. |
||
} | ||
|
||
func testLocalesOrderedByPriority() throws { | ||
let expected: [String] | ||
|
||
if #available(iOS 17.0, tvOS 17, watchOS 10, *) { | ||
expected = [ | ||
"en_US", | ||
"en-US", | ||
"en" | ||
] | ||
} else { | ||
expected = [ | ||
"en_US", | ||
// `Locale.preferredLanguages` returns `en` before iOS 17. | ||
"en", | ||
"en" | ||
] | ||
} | ||
|
||
expect(PaywallData.localesOrderedByPriority.map(\.identifier)) == expected | ||
} | ||
|
||
func testDoesNotFindLocaleWithMissingLanguage() throws { | ||
let paywall: PaywallData = try self.decodeFixture("PaywallData-Sample1") | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fix