16
16
17
17
static CGFloat const IterableNetworkResponseExpectationTimeout = 5.0 ;
18
18
19
- @interface IterableAPIInternalTests : XCTestCase
19
+ @interface IterableAPIObjCTests : XCTestCase
20
20
@end
21
21
22
- @implementation IterableAPIInternalTests
22
+ @implementation IterableAPIObjCTests
23
23
24
24
NSString *redirectRequest = @" https://httpbin.org/redirect-to?url=http://example.com" ;
25
25
NSString *exampleUrl = @" http://example.com" ;
@@ -31,28 +31,14 @@ @implementation IterableAPIInternalTests
31
31
32
32
- (void )setUp {
33
33
[super setUp ];
34
- [IterableAPIInternal initializeWithApiKey: @" " ];
34
+ [IterableAPI initializeWithApiKey: @" " ];
35
35
}
36
36
37
37
- (void )tearDown {
38
38
// Put teardown code here. This method is called after the invocation of each test method in the class.
39
39
[super tearDown ];
40
40
}
41
41
42
- - (void )testPushServicePlatformToString {
43
- XCTAssertEqualObjects (@" APNS" , [IterableAPIInternal pushServicePlatformToString: APNS]);
44
- XCTAssertEqualObjects (@" APNS_SANDBOX" , [IterableAPIInternal pushServicePlatformToString: APNS_SANDBOX]);
45
- }
46
-
47
- - (void )testUserInterfaceIdionEnumToString {
48
- XCTAssertEqualObjects (@" Phone" , [IterableAPIInternal userInterfaceIdiomEnumToString: UIUserInterfaceIdiomPhone]);
49
- XCTAssertEqualObjects (@" Pad" , [IterableAPIInternal userInterfaceIdiomEnumToString: UIUserInterfaceIdiomPad]);
50
- // we don't care about TVs for now
51
- XCTAssertEqualObjects (@" Unspecified" , [IterableAPIInternal userInterfaceIdiomEnumToString: UIUserInterfaceIdiomTV]);
52
- XCTAssertEqualObjects (@" Unspecified" , [IterableAPIInternal userInterfaceIdiomEnumToString: UIUserInterfaceIdiomUnspecified]);
53
- XCTAssertEqualObjects (@" Unspecified" , [IterableAPIInternal userInterfaceIdiomEnumToString: 192387 ]);
54
- }
55
-
56
42
- (void )testUniversalDeeplinkRewrite {
57
43
XCTestExpectation *expectation = [self expectationWithDescription: @" High Expectations" ];
58
44
NSURL *iterableLink = [NSURL URLWithString: iterableRewriteURL];
@@ -61,7 +47,7 @@ - (void)testUniversalDeeplinkRewrite {
61
47
XCTAssertTrue (NSThread .isMainThread );
62
48
[expectation fulfill ];
63
49
};
64
- [IterableAPIInternal getAndTrackDeeplink: iterableLink callbackBlock: aBlock];
50
+ [IterableAPI getAndTrackDeeplink: iterableLink callbackBlock: aBlock];
65
51
66
52
[self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
67
53
}
@@ -73,7 +59,7 @@ - (void)testUniversalDeeplinkNoRewrite {
73
59
XCTAssertEqualObjects (iterableNoRewriteURL, redirectUrl);
74
60
[expectation fulfill ];
75
61
};
76
- [IterableAPIInternal getAndTrackDeeplink: normalLink callbackBlock: uBlock];
62
+ [IterableAPI getAndTrackDeeplink: normalLink callbackBlock: uBlock];
77
63
78
64
[self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
79
65
}
@@ -90,9 +76,9 @@ - (void)testHandleUniversalLinkRewrite {
90
76
91
77
IterableConfig *config = [[IterableConfig alloc ] init ];
92
78
config.urlDelegate = urlDelegateMock;
93
- [IterableAPIInternal initializeWithApiKey: @" " config: config];
79
+ [IterableAPI initializeWithApiKey: @" " config: config];
94
80
NSURL *iterableLink = [NSURL URLWithString: iterableRewriteURL];
95
- [[IterableAPIInternal sharedInstance ] handleUniversalLink: iterableLink];
81
+ [IterableAPI handleUniversalLink: iterableLink];
96
82
97
83
[self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
98
84
}
@@ -105,12 +91,12 @@ - (void)testDeeplinkAttributionInfo {
105
91
XCTestExpectation *expectation = [self expectationWithDescription: @" High Expectations" ];
106
92
NSURL *normalLink = [NSURL URLWithString: iterableRewriteURL];
107
93
ITEActionBlock uBlock = ^(NSString * redirectUrl) {
108
- XCTAssertEqualObjects (IterableAPIInternal. sharedInstance .attributionInfo .campaignId , campaignId);
109
- XCTAssertEqualObjects (IterableAPIInternal. sharedInstance .attributionInfo .templateId , templateId);
110
- XCTAssertEqualObjects (IterableAPIInternal. sharedInstance .attributionInfo .messageId , messageId);
94
+ XCTAssertEqualObjects (IterableAPI .attributionInfo .campaignId , campaignId);
95
+ XCTAssertEqualObjects (IterableAPI .attributionInfo .templateId , templateId);
96
+ XCTAssertEqualObjects (IterableAPI .attributionInfo .messageId , messageId);
111
97
[expectation fulfill ];
112
98
};
113
- [IterableAPIInternal getAndTrackDeeplink: normalLink callbackBlock: uBlock];
99
+ [IterableAPI getAndTrackDeeplink: normalLink callbackBlock: uBlock];
114
100
115
101
[self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
116
102
}
@@ -123,7 +109,7 @@ - (void)testNoURLRedirect {
123
109
XCTAssertNotEqual (exampleUrl, redirectUrl);
124
110
XCTAssertEqualObjects (redirectRequest, redirectUrl);
125
111
};
126
- [IterableAPIInternal getAndTrackDeeplink: redirectLink callbackBlock: redirectBlock];
112
+ [IterableAPI getAndTrackDeeplink: redirectLink callbackBlock: redirectBlock];
127
113
128
114
[self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
129
115
}
@@ -136,7 +122,7 @@ - (void)testUniversalDeeplinkHttp {
136
122
XCTAssertEqualObjects (googleHttps, redirectUrl);
137
123
XCTAssertNotEqual (googleHttp, redirectUrl);
138
124
};
139
- [IterableAPIInternal getAndTrackDeeplink: googleHttpLink callbackBlock: googleHttpBlock];
125
+ [IterableAPI getAndTrackDeeplink: googleHttpLink callbackBlock: googleHttpBlock];
140
126
141
127
[self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
142
128
}
@@ -150,47 +136,11 @@ - (void)testUniversalDeeplinkHttps {
150
136
[expectation fulfill ];
151
137
XCTAssertEqualObjects (googleHttps, redirectUrl);
152
138
};
153
- [IterableAPIInternal getAndTrackDeeplink: googleHttpsLink callbackBlock: googleHttpsBlock];
139
+ [IterableAPI getAndTrackDeeplink: googleHttpsLink callbackBlock: googleHttpsBlock];
154
140
155
141
[self waitForExpectationsWithTimeout: IterableNetworkResponseExpectationTimeout handler: nil ];
156
142
}
157
143
158
- - (void )testURLQueryParamRewrite {
159
- [IterableAPIInternal initializeWithApiKey: @" " ];
160
-
161
- NSCharacterSet * set = [NSCharacterSet URLQueryAllowedCharacterSet ];
162
-
163
- NSMutableString * strSet =[NSMutableString string ];
164
- for (int plane = 0 ; plane <= 16 ; plane++) {
165
- if ([set hasMemberInPlane: plane]) {
166
- UTF32Char c;
167
- for (c = plane << 16 ; c < (plane+1 ) << 16 ; c++) {
168
- if ([set longCharacterIsMember: c]) {
169
- UTF32Char c1 = OSSwapHostToLittleInt32 (c);
170
- NSString *s = [[NSString alloc ] initWithBytes: &c1 length: 4 encoding: NSUTF32LittleEndianStringEncoding];
171
- [strSet appendString: s];
172
- }
173
- }
174
- }
175
- }
176
-
177
- // Test full set of possible URLQueryAllowedCharacterSet characters
178
- NSString * encodedSet = [[IterableAPIInternal sharedInstance ] encodeURLParam: strSet];
179
- XCTAssertNotEqual (encodedSet, strSet);
180
- XCTAssert ([encodedSet isEqualToString: @" !$&'()*%2B,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~" ]);
181
-
182
- NSString * encoded = [[IterableAPIInternal
sharedInstance ]
encodeURLParam: @" [email protected] " ];
183
- XCTAssertNotEqual (encoded,
@" [email protected] " );
184
- XCTAssert ([encoded
isEqualToString: @" you%[email protected] " ]);
185
-
186
- NSString * emptySet = [[IterableAPIInternal sharedInstance ] encodeURLParam: @" " ];
187
- XCTAssertEqual (emptySet, @" " );
188
- XCTAssert ([emptySet isEqualToString: @" " ]);
189
-
190
- NSString * nilSet = [[IterableAPIInternal sharedInstance ] encodeURLParam: nil ];
191
- XCTAssertEqualObjects (nilSet, nil );
192
- }
193
-
194
144
- (void )testRegisterToken {
195
145
XCTestExpectation *expectation = [[XCTestExpectation alloc ] initWithDescription: @" Request is sent" ];
196
146
[OHHTTPStubs stubRequestsPassingTest: ^BOOL (NSURLRequest *request) {
@@ -209,27 +159,27 @@ - (void)testRegisterToken {
209
159
210
160
IterableConfig *config = [[IterableConfig alloc ] init ];
211
161
config.pushIntegrationName = @" pushIntegration" ;
212
- [IterableAPIInternal initializeWithApiKey: @" apiKey" config: config];
213
- [[IterableAPIInternal sharedInstance ] setEmail: @" [email protected] " ] ;
214
- [[IterableAPIInternal sharedInstance ] registerToken: [@" token" dataUsingEncoding: kCFStringEncodingUTF8 ]];
162
+ [IterableAPI initializeWithApiKey: @" apiKey" config: config];
163
+ IterableAPI. email = @" [email protected] " ;
164
+ [IterableAPI registerToken: [@" token" dataUsingEncoding: kCFStringEncodingUTF8 ]];
215
165
216
166
[self waitForExpectations: @[expectation] timeout: 5.0 ];
217
167
[OHHTTPStubs removeAllStubs ];
218
168
}
219
169
220
170
- (void )testEmailUserIdPersistence {
221
- [IterableAPIInternal initializeWithApiKey: @" apiKey" ];
222
- [[IterableAPIInternal sharedInstance ] setEmail: @" [email protected] " ] ;
171
+ [IterableAPI initializeWithApiKey: @" apiKey" ];
172
+ IterableAPI. email = @" [email protected] " ;
223
173
224
- [IterableAPIInternal initializeWithApiKey: @" apiKey" ];
225
- XCTAssertEqualObjects (
[IterableAPIInternal sharedInstance ] .
email ,
@" [email protected] " );
226
- XCTAssertNil ([IterableAPIInternal sharedInstance ] .userId );
174
+ [IterableAPI initializeWithApiKey: @" apiKey" ];
175
+ XCTAssertEqualObjects (
IterableAPI .
email ,
@" [email protected] " );
176
+ XCTAssertNil (IterableAPI .userId );
227
177
228
- [[IterableAPIInternal sharedInstance ] setUserId: @" testUserId" ] ;
178
+ IterableAPI. userId = @" testUserId" ;
229
179
230
- [IterableAPIInternal initializeWithApiKey: @" apiKey" ];
231
- XCTAssertEqualObjects ([IterableAPIInternal sharedInstance ] .userId , @" testUserId" );
232
- XCTAssertNil ([IterableAPIInternal sharedInstance ] .email );
180
+ [IterableAPI initializeWithApiKey: @" apiKey" ];
181
+ XCTAssertEqualObjects (IterableAPI .userId , @" testUserId" );
182
+ XCTAssertNil (IterableAPI .email );
233
183
}
234
184
235
185
0 commit comments