Skip to content
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

Merged
merged 7 commits into from
Oct 13, 2017

Conversation

bdorfman-stripe
Copy link
Contributor

This copies over a small subset of the sources-ui branch to allow for reading saved source objects from customer and using them in STPPaymentMethodsViewController.

It also fixes snapshot tests for that class which appear to have been broken and erroneously passing for quite a while.

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.
Copy link
Contributor

@bg-stripe bg-stripe left a 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

[paymentMethods addObject:card];
}
+ (instancetype)tupleWithPaymentMethods:(NSArray<id<STPPaymentMethod>> *)paymentMethods
selectedPaymentMethod:(id<STPPaymentMethod>)selectedPaymentMethod
Copy link
Contributor

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_NONNULLs and annotate this as nullable?

Copy link
Contributor Author

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]]);
Copy link
Contributor

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.

Copy link
Contributor Author

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.
@bdorfman-stripe
Copy link
Contributor Author

Ready for re-review I think. Also added some fixtures code that should help our Customer testing a bunch going forward.

Copy link
Contributor

@bg-stripe bg-stripe left a 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,
Copy link
Contributor

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 ✨

@@ -10,6 +10,17 @@
#import "STPTestUtils.h"
#import "STPEphemeralKey.h"

NSString *const STPJSONKeyCustomer = @"Customer";
Copy link
Contributor

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?

Copy link
Contributor Author

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

@bdorfman-stripe
Copy link
Contributor Author

Constants renamed. Also fixed description of one of the test methods which I realized was slightly incorrect.

@bdorfman-stripe bdorfman-stripe merged commit c90f6f1 into master Oct 13, 2017
@bdorfman-stripe bdorfman-stripe deleted the bdorfman-saved-card-sources-paycontext branch October 13, 2017 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants