11//
2- // IterableAPITests.m
3- // Iterable-iOS-SDK
42//
53// Created by Ilya Brin on 5/25/16.
64// Copyright © 2016 Iterable. All rights reserved.
1816
1917static CGFloat const IterableNetworkResponseExpectationTimeout = 5.0 ;
2018
21- @interface IterableAPITests : XCTestCase
19+ @interface IterableAPIImplementationTests : XCTestCase
2220@end
2321
24- @implementation IterableAPITests
22+ @implementation IterableAPIImplementationTests
2523
2624NSString *redirectRequest = @" https://httpbin.org/redirect-to?url=http://example.com" ;
2725NSString *exampleUrl = @" http://example.com" ;
@@ -33,8 +31,7 @@ @implementation IterableAPITests
3331
3432- (void )setUp {
3533 [super setUp ];
36-
37- [IterableAPI initializeWithApiKey: @" " ];
34+ [IterableAPIImplementation initializeWithApiKey: @" " ];
3835}
3936
4037- (void )tearDown {
@@ -43,8 +40,8 @@ - (void)tearDown {
4340}
4441
4542- (void )testPushServicePlatformToString {
46- XCTAssertEqualObjects (@" APNS" , [IterableAPI pushServicePlatformToString: APNS]);
47- XCTAssertEqualObjects (@" APNS_SANDBOX" , [IterableAPI pushServicePlatformToString: APNS_SANDBOX]);
43+ XCTAssertEqualObjects (@" APNS" , [IterableAPIImplementation pushServicePlatformToString: APNS]);
44+ XCTAssertEqualObjects (@" APNS_SANDBOX" , [IterableAPIImplementation pushServicePlatformToString: APNS_SANDBOX]);
4845}
4946
5047- (void )testDictToJson {
@@ -65,7 +62,7 @@ - (void)testDictToJson {
6562 }
6663 }
6764 };
68- NSString *result = [IterableAPI dictToJson: args];
65+ NSString *result = [IterableAPIImplementation dictToJson: args];
6966 NSData *data = [result dataUsingEncoding: NSUTF8StringEncoding];
7067 id json = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil ];
7168 XCTAssertEqualObjects (args, json);
@@ -81,12 +78,12 @@ - (void)testDictToJson {
8178}
8279
8380- (void )testUserInterfaceIdionEnumToString {
84- XCTAssertEqualObjects (@" Phone" , [IterableAPI userInterfaceIdiomEnumToString: UIUserInterfaceIdiomPhone]);
85- XCTAssertEqualObjects (@" Pad" , [IterableAPI userInterfaceIdiomEnumToString: UIUserInterfaceIdiomPad]);
81+ XCTAssertEqualObjects (@" Phone" , [IterableAPIImplementation userInterfaceIdiomEnumToString: UIUserInterfaceIdiomPhone]);
82+ XCTAssertEqualObjects (@" Pad" , [IterableAPIImplementation userInterfaceIdiomEnumToString: UIUserInterfaceIdiomPad]);
8683 // we don't care about TVs for now
87- XCTAssertEqualObjects (@" Unspecified" , [IterableAPI userInterfaceIdiomEnumToString: UIUserInterfaceIdiomTV]);
88- XCTAssertEqualObjects (@" Unspecified" , [IterableAPI userInterfaceIdiomEnumToString: UIUserInterfaceIdiomUnspecified]);
89- XCTAssertEqualObjects (@" Unspecified" , [IterableAPI userInterfaceIdiomEnumToString: 192387 ]);
84+ XCTAssertEqualObjects (@" Unspecified" , [IterableAPIImplementation userInterfaceIdiomEnumToString: UIUserInterfaceIdiomTV]);
85+ XCTAssertEqualObjects (@" Unspecified" , [IterableAPIImplementation userInterfaceIdiomEnumToString: UIUserInterfaceIdiomUnspecified]);
86+ XCTAssertEqualObjects (@" Unspecified" , [IterableAPIImplementation userInterfaceIdiomEnumToString: 192387 ]);
9087}
9188
9289- (void )testUniversalDeeplinkRewrite {
@@ -97,7 +94,7 @@ - (void)testUniversalDeeplinkRewrite {
9794 XCTAssertTrue (NSThread .isMainThread );
9895 [expectation fulfill ];
9996 };
100- [IterableAPI getAndTrackDeeplink: iterableLink callbackBlock: aBlock];
97+ [IterableAPIImplementation getAndTrackDeeplink: iterableLink callbackBlock: aBlock];
10198
10299 [self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
103100}
@@ -109,7 +106,7 @@ - (void)testUniversalDeeplinkNoRewrite {
109106 XCTAssertEqualObjects (iterableNoRewriteURL, redirectUrl);
110107 [expectation fulfill ];
111108 };
112- [IterableAPI getAndTrackDeeplink: normalLink callbackBlock: uBlock];
109+ [IterableAPIImplementation getAndTrackDeeplink: normalLink callbackBlock: uBlock];
113110
114111 [self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
115112}
@@ -126,9 +123,9 @@ - (void)testHandleUniversalLinkRewrite {
126123
127124 IterableConfig *config = [[IterableConfig alloc ] init ];
128125 config.urlDelegate = urlDelegateMock;
129- [IterableAPI initializeWithApiKey: @" " config: config];
126+ [IterableAPIImplementation initializeWithApiKey: @" " config: config];
130127 NSURL *iterableLink = [NSURL URLWithString: iterableRewriteURL];
131- [IterableAPI handleUniversalLink: iterableLink];
128+ [IterableAPIImplementation handleUniversalLink: iterableLink];
132129
133130 [self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
134131}
@@ -141,12 +138,12 @@ - (void)testDeeplinkAttributionInfo {
141138 XCTestExpectation *expectation = [self expectationWithDescription: @" High Expectations" ];
142139 NSURL *normalLink = [NSURL URLWithString: iterableRewriteURL];
143140 ITEActionBlock uBlock = ^(NSString * redirectUrl) {
144- XCTAssertEqualObjects (IterableAPI .sharedInstance .attributionInfo .campaignId , campaignId);
145- XCTAssertEqualObjects (IterableAPI .sharedInstance .attributionInfo .templateId , templateId);
146- XCTAssertEqualObjects (IterableAPI .sharedInstance .attributionInfo .messageId , messageId);
141+ XCTAssertEqualObjects (IterableAPIImplementation .sharedInstance .attributionInfo .campaignId , campaignId);
142+ XCTAssertEqualObjects (IterableAPIImplementation .sharedInstance .attributionInfo .templateId , templateId);
143+ XCTAssertEqualObjects (IterableAPIImplementation .sharedInstance .attributionInfo .messageId , messageId);
147144 [expectation fulfill ];
148145 };
149- [IterableAPI getAndTrackDeeplink: normalLink callbackBlock: uBlock];
146+ [IterableAPIImplementation getAndTrackDeeplink: normalLink callbackBlock: uBlock];
150147
151148 [self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
152149}
@@ -159,7 +156,7 @@ - (void)testNoURLRedirect {
159156 XCTAssertNotEqual (exampleUrl, redirectUrl);
160157 XCTAssertEqualObjects (redirectRequest, redirectUrl);
161158 };
162- [IterableAPI getAndTrackDeeplink: redirectLink callbackBlock: redirectBlock];
159+ [IterableAPIImplementation getAndTrackDeeplink: redirectLink callbackBlock: redirectBlock];
163160
164161 [self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
165162}
@@ -172,7 +169,7 @@ - (void)testUniversalDeeplinkHttp {
172169 XCTAssertEqualObjects (googleHttps, redirectUrl);
173170 XCTAssertNotEqual (googleHttp, redirectUrl);
174171 };
175- [IterableAPI getAndTrackDeeplink: googleHttpLink callbackBlock: googleHttpBlock];
172+ [IterableAPIImplementation getAndTrackDeeplink: googleHttpLink callbackBlock: googleHttpBlock];
176173
177174 [self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
178175}
@@ -186,13 +183,13 @@ - (void)testUniversalDeeplinkHttps {
186183 [expectation fulfill ];
187184 XCTAssertEqualObjects (googleHttps, redirectUrl);
188185 };
189- [IterableAPI getAndTrackDeeplink: googleHttpsLink callbackBlock: googleHttpsBlock];
186+ [IterableAPIImplementation getAndTrackDeeplink: googleHttpsLink callbackBlock: googleHttpsBlock];
190187
191188 [self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
192189}
193190
194191- (void )testURLQueryParamRewrite {
195- [IterableAPI initializeWithApiKey: @" " ];
192+ [IterableAPIImplementation initializeWithApiKey: @" " ];
196193
197194 NSCharacterSet * set = [NSCharacterSet URLQueryAllowedCharacterSet ];
198195
@@ -211,19 +208,19 @@ - (void)testURLQueryParamRewrite {
211208 }
212209
213210 // Test full set of possible URLQueryAllowedCharacterSet characters
214- NSString * encodedSet = [[IterableAPI sharedInstance ] encodeURLParam: strSet];
211+ NSString * encodedSet = [[IterableAPIImplementation sharedInstance ] encodeURLParam: strSet];
215212 XCTAssertNotEqual (encodedSet, strSet);
216213 XCTAssert ([encodedSet isEqualToString: @" !$&'()*%2B,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~" ]);
217214
218- NSString * encoded = [[
IterableAPI sharedInstance ]
encodeURLParam: @" [email protected] " ];
215+ NSString * encoded = [[
IterableAPIImplementation sharedInstance ]
encodeURLParam: @" [email protected] " ];
219216 XCTAssertNotEqual (encoded,
@" [email protected] " );
220217 XCTAssert ([encoded
isEqualToString: @" you%[email protected] " ]);
221218
222- NSString * emptySet = [[IterableAPI sharedInstance ] encodeURLParam: @" " ];
219+ NSString * emptySet = [[IterableAPIImplementation sharedInstance ] encodeURLParam: @" " ];
223220 XCTAssertEqual (emptySet, @" " );
224221 XCTAssert ([emptySet isEqualToString: @" " ]);
225222
226- NSString * nilSet = [[IterableAPI sharedInstance ] encodeURLParam: nil ];
223+ NSString * nilSet = [[IterableAPIImplementation sharedInstance ] encodeURLParam: nil ];
227224 XCTAssertEqualObjects (nilSet, nil );
228225}
229226
@@ -245,27 +242,27 @@ - (void)testRegisterToken {
245242
246243 IterableConfig *config = [[IterableConfig alloc ] init ];
247244 config.pushIntegrationName = @" pushIntegration" ;
248- [IterableAPI initializeWithApiKey: @" apiKey" config: config];
249- [[
IterableAPI sharedInstance ]
setEmail: @" [email protected] " ];
250- [[IterableAPI sharedInstance ] registerToken: [@" token" dataUsingEncoding: kCFStringEncodingUTF8 ]];
245+ [IterableAPIImplementation initializeWithApiKey: @" apiKey" config: config];
246+ [[
IterableAPIImplementation sharedInstance ]
setEmail: @" [email protected] " ];
247+ [[IterableAPIImplementation sharedInstance ] registerToken: [@" token" dataUsingEncoding: kCFStringEncodingUTF8 ]];
251248
252249 [self waitForExpectations: @[expectation] timeout: 5.0 ];
253250 [OHHTTPStubs removeAllStubs ];
254251}
255252
256253- (void )testEmailUserIdPersistence {
257- [IterableAPI initializeWithApiKey: @" apiKey" ];
258- [[
IterableAPI sharedInstance ]
setEmail: @" [email protected] " ];
254+ [IterableAPIImplementation initializeWithApiKey: @" apiKey" ];
255+ [[
IterableAPIImplementation sharedInstance ]
setEmail: @" [email protected] " ];
259256
260- [IterableAPI initializeWithApiKey: @" apiKey" ];
261- XCTAssertEqualObjects ([
IterableAPI sharedInstance ].
email ,
@" [email protected] " );
262- XCTAssertNil ([IterableAPI sharedInstance ].userId );
257+ [IterableAPIImplementation initializeWithApiKey: @" apiKey" ];
258+ XCTAssertEqualObjects ([
IterableAPIImplementation sharedInstance ].
email ,
@" [email protected] " );
259+ XCTAssertNil ([IterableAPIImplementation sharedInstance ].userId );
263260
264- [[IterableAPI sharedInstance ] setUserId: @" testUserId" ];
261+ [[IterableAPIImplementation sharedInstance ] setUserId: @" testUserId" ];
265262
266- [IterableAPI initializeWithApiKey: @" apiKey" ];
267- XCTAssertEqualObjects ([IterableAPI sharedInstance ].userId , @" testUserId" );
268- XCTAssertNil ([IterableAPI sharedInstance ].email );
263+ [IterableAPIImplementation initializeWithApiKey: @" apiKey" ];
264+ XCTAssertEqualObjects ([IterableAPIImplementation sharedInstance ].userId , @" testUserId" );
265+ XCTAssertNil ([IterableAPIImplementation sharedInstance ].email );
269266}
270267
271268
0 commit comments