Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of changes
BTSEPADirectDebitClient_Tests.testTokenizeWithPresentationContext_handleCreateMandateReturnsInvalidURL_returnsError_andSendsAnalytics()
cannedErrorResponse
here which wasn't needed and was actually returning before the method completedBTJSON_Tests.testLargerMixedJSONWithEmoji()
"aString": "Hello, JSON 😍!"
and"anInvalidURL": ":™£¢://://://???!!!"
were failing to evaluate asnil
when callingBTJSON.asURL()
- neither of these are URLs so we expect that method to evaluate asnil
urlString.utf8.count == urlString.utf16.count
allows us to evaluate the string in the same way that we were in Obj-CThe Why
I found this super interesting so adding it here if other folks are also interested:
NSString
- these are UTF-16 (more reading here)String
- these are UTF-8 (more reading here)testLargerMixedJSONWithEmoji
test has been failing because "😍" is 2 extra bytes in UTF-8 vs UTF-16 and "™£¢" is 4 extra bytes in UTF-8 vs UTF-16Alternatives
There are some alternatives to the check I added here that we can explore, but the approach I took was the closest to our v5 implementation here which used
asString
to see if it could be cast to aNSString
(UTF-16) and if not returnednull
. Some alternatives:urlString
toNSString
- downside, we would then need to cast it back to a string inreturn URL(string: urlString)
becauseNSString
is not implicitly convertible toString
UIApplication.shared.canOpenURL
could be an option but we would need to replace our URLs in tests with actual URLs. This also seems like overkill a bit imo, but open to opinions!Checklist
[ ] Added a changelog entryAuthors