Skip to content

Commit

Permalink
Adds test to catch zip code switching regressions in STPShippingAddre…
Browse files Browse the repository at this point in the history
…ssViewController
  • Loading branch information
csabol-stripe committed Aug 7, 2018
1 parent fe5b1aa commit 70e2b83
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Stripe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
04FCFA191BD59A8C00297732 /* STPCategoryLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 04FCFA171BD59A8C00297732 /* STPCategoryLoader.h */; };
3617A51420FE5BBB001A9E6A /* NSLocale+STPSwizzling.h in Headers */ = {isa = PBXBuildFile; fileRef = 3617A51220FE5BBB001A9E6A /* NSLocale+STPSwizzling.h */; };
3617A51520FE5BBB001A9E6A /* NSLocale+STPSwizzling.m in Sources */ = {isa = PBXBuildFile; fileRef = 3617A51320FE5BBB001A9E6A /* NSLocale+STPSwizzling.m */; };
3691EB74211A4F31008C49E1 /* STPShippingAddressViewControllerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 3691EB73211A4F31008C49E1 /* STPShippingAddressViewControllerTest.m */; };
8B013C891F1E784A00DD831B /* STPPaymentConfigurationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B013C881F1E784A00DD831B /* STPPaymentConfigurationTest.m */; };
8B429AD81EF9D4B400F95F34 /* STPBankAccountParams+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 8B429AD71EF9D4A300F95F34 /* STPBankAccountParams+Private.h */; };
8B429AD91EF9D4B500F95F34 /* STPBankAccountParams+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 8B429AD71EF9D4A300F95F34 /* STPBankAccountParams+Private.h */; };
Expand Down Expand Up @@ -1040,6 +1041,7 @@
11C74B9B164043050071C2CA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
3617A51220FE5BBB001A9E6A /* NSLocale+STPSwizzling.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSLocale+STPSwizzling.h"; sourceTree = "<group>"; };
3617A51320FE5BBB001A9E6A /* NSLocale+STPSwizzling.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSLocale+STPSwizzling.m"; sourceTree = "<group>"; };
3691EB73211A4F31008C49E1 /* STPShippingAddressViewControllerTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPShippingAddressViewControllerTest.m; sourceTree = "<group>"; };
4A0D74F918F6106100966D7B /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
7E0B1132203572FB00271AD3 /* fi */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = fi; path = Localizations/fi.lproj/Localizable.strings; sourceTree = "<group>"; };
8B013C881F1E784A00DD831B /* STPPaymentConfigurationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STPPaymentConfigurationTest.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1675,6 +1677,7 @@
C1EEDCC91CA2186300A54582 /* STPPhoneNumberValidatorTest.m */,
C1FEE5981CBFF24000A7632B /* STPPostalCodeValidatorTest.m */,
F152321A1EA92F9D00D65C67 /* STPRedirectContextTest.m */,
3691EB73211A4F31008C49E1 /* STPShippingAddressViewControllerTest.m */,
8BD87B8A1EFB136F00269C2B /* STPSourceCardDetailsTest.m */,
8B5B4B431EFDD925005CF475 /* STPSourceOwnerTest.m */,
C1BD9B1E1E390A2700CEE925 /* STPSourceParamsTest.m */,
Expand Down Expand Up @@ -2844,6 +2847,7 @@
C1054F911FE197AE0033C87E /* STPPaymentContextSnapshotTests.m in Sources */,
C127110A1DBA7E490087840D /* STPAddressViewModelTest.m in Sources */,
C17D24EE1E37DBAC005CB188 /* STPSourceTest.m in Sources */,
3691EB74211A4F31008C49E1 /* STPShippingAddressViewControllerTest.m in Sources */,
C1E4F8061EBBEB0F00E611F5 /* STPCustomerContextTest.m in Sources */,
B3302F4C200700AB005DDBE9 /* STPLegalEntityParamsTest.m in Sources */,
F14C872F1D4FCDBA00C7CC6A /* STPPaymentContextApplePayTest.m in Sources */,
Expand Down
73 changes: 73 additions & 0 deletions Tests/Tests/STPShippingAddressViewControllerTest.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// STPShippingAddressViewControllerTest.m
// StripeiOS Tests
//
// Created by Cameron Sabol on 8/7/18.
// Copyright © 2018 Stripe, Inc. All rights reserved.
//

#import <XCTest/XCTest.h>

#import <Stripe/Stripe.h>
#import "NSLocale+STPSwizzling.h"
#import "STPFixtures.h"

@interface STPShippingAddressViewControllerTest : XCTestCase

@end

@implementation STPShippingAddressViewControllerTest

- (void)testPrefilledBillingAddress_removeAddress {
STPPaymentConfiguration *config = [STPFixtures paymentConfiguration];
config.requiredShippingAddressFields = [NSSet setWithObject:STPContactFieldPostalAddress];

STPAddress *address = [STPAddress new];
address.name = @"John Smith Doe";
address.phone = @"8885551212";
address.email = @"[email protected]";
address.line1 = @"55 John St";
address.city = @"Harare";
address.postalCode = @"10002";
address.country = @"ZW";

STPShippingAddressViewController *sut = [[STPShippingAddressViewController alloc] initWithConfiguration:config
theme:[STPTheme defaultTheme]
currency:nil
shippingAddress:address
selectedShippingMethod:nil
prefilledInformation:nil];

[sut loadView];
[sut viewDidLoad];
}

- (void)testPrefilledBillingAddress_addAddress {
[NSLocale stp_setCurrentLocale:[NSLocale localeWithLocaleIdentifier:@"en_ZW"]];
STPPaymentConfiguration *config = [STPFixtures paymentConfiguration];
config.requiredShippingAddressFields = [NSSet setWithObject:STPContactFieldPostalAddress];

STPAddress *address = [STPAddress new];
address.name = @"John Smith Doe";
address.phone = @"8885551212";
address.email = @"[email protected]";
address.line1 = @"55 John St";
address.city = @"New York";
address.state = @"NY";
address.postalCode = @"10002";
address.country = @"US";

STPShippingAddressViewController *sut = [[STPShippingAddressViewController alloc] initWithConfiguration:config
theme:[STPTheme defaultTheme]
currency:nil
shippingAddress:address
selectedShippingMethod:nil
prefilledInformation:nil];

[sut loadView];
[sut viewDidLoad];
[NSLocale stp_resetCurrentLocale];
}


@end

0 comments on commit 70e2b83

Please sign in to comment.