-
Notifications
You must be signed in to change notification settings - Fork 982
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
Support saved card sources in UI elements #810
Support saved card sources in UI elements #810
Conversation
This moves over a small subset of `sources-ui` branch changes to support viewing and using card type source objects attached to customers to show up and be usable by STPPaymentContext and STPPaymentMethodsViewController.
Fix payment methods vc snapshot test logic which was erroneously passing. Also update cell logic to render source info correctly.
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.
nice! just one nit
Stripe/STPPaymentMethodTuple.m
Outdated
[paymentMethods addObject:card]; | ||
} | ||
+ (instancetype)tupleWithPaymentMethods:(NSArray<id<STPPaymentMethod>> *)paymentMethods | ||
selectedPaymentMethod:(id<STPPaymentMethod>)selectedPaymentMethod |
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.
nit: can we wrap this file with NS_ASSUME_NONNULL
s and annotate this as nullable
?
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.
Yep I'll make the change.
STPPaymentMethodsViewController *sut = [self buildViewControllerWithCustomer:customer | ||
configuration:config | ||
delegate:delegate]; | ||
XCTAssertTrue([sut.internalViewController isKindOfClass:[STPPaymentMethodsInternalViewController class]]); |
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.
can we also check that the internal paymentMethods
and selectedPaymentMethod
props are set to the expected values?
alternatively, we could add some tests for filteredSourceTupleForUIWithConfiguration
, and avoid exposing those internal properties to tests.
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.
I'll just add some tests for filter 👍
Adds a bunch of tests for parsing source tuples with customers in various configurations. Also: Adds constants for the file names of many json test files. Adds a customer fixture builder function that allows you to pass in arbitrary json source keys to build a customer with those sources in that order.
Ready for re-review I think. Also added some fixtures code that should help our Customer testing a bunch going forward. |
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.
nice, just one naming nit, otherwise lgtm!
|
||
|
||
- (void)testSourceTupleCreationMixedValidAndInvalidSourcesWithInvalidDefaultCustomer { | ||
STPCustomer *customer = [STPFixtures customerWithSourcesFromJSONKeys:@[STPJSONKeySource3DS, |
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.
nice, these tests are really clean ✨
Tests/Tests/STPFixtures.m
Outdated
@@ -10,6 +10,17 @@ | |||
#import "STPTestUtils.h" | |||
#import "STPEphemeralKey.h" | |||
|
|||
NSString *const STPJSONKeyCustomer = @"Customer"; |
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.
nit: not sure about STPJSONKey
as a name, since it kinda looks like these are constants from the SDK. Maybe something like STPTestJSON
?
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.
Good idea. I wasn't sure what to call them. As I was working I renamed all of them 3-4 times before pushing this :P
Constants renamed. Also fixed description of one of the test methods which I realized was slightly incorrect. |
This copies over a small subset of the
sources-ui
branch to allow for reading saved source objects from customer and using them inSTPPaymentMethodsViewController
.It also fixes snapshot tests for that class which appear to have been broken and erroneously passing for quite a while.