1
1
//
2
- // IterableAPITests.m
3
- // Iterable-iOS-SDK
4
2
//
5
3
// Created by Ilya Brin on 5/25/16.
6
4
// Copyright © 2016 Iterable. All rights reserved.
18
16
19
17
static CGFloat const IterableNetworkResponseExpectationTimeout = 5.0 ;
20
18
21
- @interface IterableAPITests : XCTestCase
19
+ @interface IterableAPIImplementationTests : XCTestCase
22
20
@end
23
21
24
- @implementation IterableAPITests
22
+ @implementation IterableAPIImplementationTests
25
23
26
24
NSString *redirectRequest = @" https://httpbin.org/redirect-to?url=http://example.com" ;
27
25
NSString *exampleUrl = @" http://example.com" ;
@@ -33,8 +31,7 @@ @implementation IterableAPITests
33
31
34
32
- (void )setUp {
35
33
[super setUp ];
36
-
37
- [IterableAPI initializeWithApiKey: @" " ];
34
+ [IterableAPIImplementation initializeWithApiKey: @" " ];
38
35
}
39
36
40
37
- (void )tearDown {
@@ -43,8 +40,8 @@ - (void)tearDown {
43
40
}
44
41
45
42
- (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]);
48
45
}
49
46
50
47
- (void )testDictToJson {
@@ -65,7 +62,7 @@ - (void)testDictToJson {
65
62
}
66
63
}
67
64
};
68
- NSString *result = [IterableAPI dictToJson: args];
65
+ NSString *result = [IterableAPIImplementation dictToJson: args];
69
66
NSData *data = [result dataUsingEncoding: NSUTF8StringEncoding];
70
67
id json = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil ];
71
68
XCTAssertEqualObjects (args, json);
@@ -81,12 +78,12 @@ - (void)testDictToJson {
81
78
}
82
79
83
80
- (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]);
86
83
// 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 ]);
90
87
}
91
88
92
89
- (void )testUniversalDeeplinkRewrite {
@@ -97,7 +94,7 @@ - (void)testUniversalDeeplinkRewrite {
97
94
XCTAssertTrue (NSThread .isMainThread );
98
95
[expectation fulfill ];
99
96
};
100
- [IterableAPI getAndTrackDeeplink: iterableLink callbackBlock: aBlock];
97
+ [IterableAPIImplementation getAndTrackDeeplink: iterableLink callbackBlock: aBlock];
101
98
102
99
[self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
103
100
}
@@ -109,7 +106,7 @@ - (void)testUniversalDeeplinkNoRewrite {
109
106
XCTAssertEqualObjects (iterableNoRewriteURL, redirectUrl);
110
107
[expectation fulfill ];
111
108
};
112
- [IterableAPI getAndTrackDeeplink: normalLink callbackBlock: uBlock];
109
+ [IterableAPIImplementation getAndTrackDeeplink: normalLink callbackBlock: uBlock];
113
110
114
111
[self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
115
112
}
@@ -126,9 +123,9 @@ - (void)testHandleUniversalLinkRewrite {
126
123
127
124
IterableConfig *config = [[IterableConfig alloc ] init ];
128
125
config.urlDelegate = urlDelegateMock;
129
- [IterableAPI initializeWithApiKey: @" " config: config];
126
+ [IterableAPIImplementation initializeWithApiKey: @" " config: config];
130
127
NSURL *iterableLink = [NSURL URLWithString: iterableRewriteURL];
131
- [IterableAPI handleUniversalLink: iterableLink];
128
+ [IterableAPIImplementation handleUniversalLink: iterableLink];
132
129
133
130
[self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
134
131
}
@@ -141,12 +138,12 @@ - (void)testDeeplinkAttributionInfo {
141
138
XCTestExpectation *expectation = [self expectationWithDescription: @" High Expectations" ];
142
139
NSURL *normalLink = [NSURL URLWithString: iterableRewriteURL];
143
140
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);
147
144
[expectation fulfill ];
148
145
};
149
- [IterableAPI getAndTrackDeeplink: normalLink callbackBlock: uBlock];
146
+ [IterableAPIImplementation getAndTrackDeeplink: normalLink callbackBlock: uBlock];
150
147
151
148
[self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
152
149
}
@@ -159,7 +156,7 @@ - (void)testNoURLRedirect {
159
156
XCTAssertNotEqual (exampleUrl, redirectUrl);
160
157
XCTAssertEqualObjects (redirectRequest, redirectUrl);
161
158
};
162
- [IterableAPI getAndTrackDeeplink: redirectLink callbackBlock: redirectBlock];
159
+ [IterableAPIImplementation getAndTrackDeeplink: redirectLink callbackBlock: redirectBlock];
163
160
164
161
[self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
165
162
}
@@ -172,7 +169,7 @@ - (void)testUniversalDeeplinkHttp {
172
169
XCTAssertEqualObjects (googleHttps, redirectUrl);
173
170
XCTAssertNotEqual (googleHttp, redirectUrl);
174
171
};
175
- [IterableAPI getAndTrackDeeplink: googleHttpLink callbackBlock: googleHttpBlock];
172
+ [IterableAPIImplementation getAndTrackDeeplink: googleHttpLink callbackBlock: googleHttpBlock];
176
173
177
174
[self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
178
175
}
@@ -186,13 +183,13 @@ - (void)testUniversalDeeplinkHttps {
186
183
[expectation fulfill ];
187
184
XCTAssertEqualObjects (googleHttps, redirectUrl);
188
185
};
189
- [IterableAPI getAndTrackDeeplink: googleHttpsLink callbackBlock: googleHttpsBlock];
186
+ [IterableAPIImplementation getAndTrackDeeplink: googleHttpsLink callbackBlock: googleHttpsBlock];
190
187
191
188
[self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
192
189
}
193
190
194
191
- (void )testURLQueryParamRewrite {
195
- [IterableAPI initializeWithApiKey: @" " ];
192
+ [IterableAPIImplementation initializeWithApiKey: @" " ];
196
193
197
194
NSCharacterSet * set = [NSCharacterSet URLQueryAllowedCharacterSet ];
198
195
@@ -211,19 +208,19 @@ - (void)testURLQueryParamRewrite {
211
208
}
212
209
213
210
// Test full set of possible URLQueryAllowedCharacterSet characters
214
- NSString * encodedSet = [[IterableAPI sharedInstance ] encodeURLParam: strSet];
211
+ NSString * encodedSet = [[IterableAPIImplementation sharedInstance ] encodeURLParam: strSet];
215
212
XCTAssertNotEqual (encodedSet, strSet);
216
213
XCTAssert ([encodedSet isEqualToString: @" !$&'()*%2B,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~" ]);
217
214
218
- NSString * encoded = [[
IterableAPI sharedInstance ]
encodeURLParam: @" [email protected] " ];
215
+ NSString * encoded = [[
IterableAPIImplementation sharedInstance ]
encodeURLParam: @" [email protected] " ];
219
216
XCTAssertNotEqual (encoded,
@" [email protected] " );
220
217
XCTAssert ([encoded
isEqualToString: @" you%[email protected] " ]);
221
218
222
- NSString * emptySet = [[IterableAPI sharedInstance ] encodeURLParam: @" " ];
219
+ NSString * emptySet = [[IterableAPIImplementation sharedInstance ] encodeURLParam: @" " ];
223
220
XCTAssertEqual (emptySet, @" " );
224
221
XCTAssert ([emptySet isEqualToString: @" " ]);
225
222
226
- NSString * nilSet = [[IterableAPI sharedInstance ] encodeURLParam: nil ];
223
+ NSString * nilSet = [[IterableAPIImplementation sharedInstance ] encodeURLParam: nil ];
227
224
XCTAssertEqualObjects (nilSet, nil );
228
225
}
229
226
@@ -245,27 +242,27 @@ - (void)testRegisterToken {
245
242
246
243
IterableConfig *config = [[IterableConfig alloc ] init ];
247
244
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 ]];
251
248
252
249
[self waitForExpectations: @[expectation] timeout: 5.0 ];
253
250
[OHHTTPStubs removeAllStubs ];
254
251
}
255
252
256
253
- (void )testEmailUserIdPersistence {
257
- [IterableAPI initializeWithApiKey: @" apiKey" ];
258
- [[
IterableAPI sharedInstance ]
setEmail: @" [email protected] " ];
254
+ [IterableAPIImplementation initializeWithApiKey: @" apiKey" ];
255
+ [[
IterableAPIImplementation sharedInstance ]
setEmail: @" [email protected] " ];
259
256
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 );
263
260
264
- [[IterableAPI sharedInstance ] setUserId: @" testUserId" ];
261
+ [[IterableAPIImplementation sharedInstance ] setUserId: @" testUserId" ];
265
262
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 );
269
266
}
270
267
271
268
0 commit comments