@@ -166,11 +166,11 @@ class IterableInAppNotificationTests: XCTestCase {
166
166
func testTrackInAppClickWithButtonUrl( ) {
167
167
let messageId = " message1 "
168
168
let buttonUrl = " http://somewhere.com "
169
- let expectation1 = expectation ( description: " track in app messages " )
169
+ let expectation1 = expectation ( description: " track in app click " )
170
170
171
171
let networkSession = MockNetworkSession ( statusCode: 200 )
172
172
IterableAPI . initialize ( apiKey: IterableInAppNotificationTests . apiKey, networkSession: networkSession)
173
- IterableAPI . email = IterableInAppNotificationTests . email
173
+ IterableAPI . userId = IterableInAppNotificationTests . userId
174
174
networkSession. callback = { ( _, _, _) in
175
175
TestUtils . validate ( request: networkSession. request!,
176
176
requestType: . post,
@@ -181,6 +181,7 @@ class IterableInAppNotificationTests: XCTestCase {
181
181
let body = networkSession. getRequestBody ( ) as! [ String : Any ]
182
182
TestUtils . validateMatch ( keyPath: KeyPath ( " messageId " ) , value: messageId, inDictionary: body)
183
183
TestUtils . validateMatch ( keyPath: KeyPath ( " urlClick " ) , value: buttonUrl, inDictionary: body)
184
+ TestUtils . validateMatch ( keyPath: KeyPath ( " userId " ) , value: IterableInAppNotificationTests . userId, inDictionary: body)
184
185
expectation1. fulfill ( )
185
186
}
186
187
IterableAPI . track ( inAppClick: messageId, buttonURL: buttonUrl)
@@ -190,7 +191,7 @@ class IterableInAppNotificationTests: XCTestCase {
190
191
func testTrackInAppClickWithButtonIndex( ) {
191
192
let messageId = " message1 "
192
193
let buttonIndex = " 1 "
193
- let expectation1 = expectation ( description: " track in app messages " )
194
+ let expectation1 = expectation ( description: " track in app click " )
194
195
195
196
let networkSession = MockNetworkSession ( statusCode: 200 )
196
197
IterableAPI . initialize ( apiKey: IterableInAppNotificationTests . apiKey, networkSession: networkSession)
@@ -205,12 +206,37 @@ class IterableInAppNotificationTests: XCTestCase {
205
206
let body = networkSession. getRequestBody ( ) as! [ String : Any ]
206
207
TestUtils . validateMatch ( keyPath: KeyPath ( " messageId " ) , value: messageId, inDictionary: body)
207
208
TestUtils . validateMatch ( keyPath: KeyPath ( " buttonIndex " ) , value: buttonIndex, inDictionary: body)
209
+ TestUtils . validateMatch ( keyPath: KeyPath ( " email " ) , value: IterableInAppNotificationTests . email, inDictionary: body)
208
210
expectation1. fulfill ( )
209
211
}
210
212
IterableAPI . track ( inAppClick: messageId, buttonIndex: buttonIndex)
211
213
wait ( for: [ expectation1] , timeout: testExpectationTimeout)
212
214
}
213
215
216
+ func testTrackInAppOpen( ) {
217
+ let messageId = " message1 "
218
+ let expectation1 = expectation ( description: " track in app open " )
219
+
220
+ let networkSession = MockNetworkSession ( statusCode: 200 )
221
+ IterableAPI . initialize ( apiKey: IterableInAppNotificationTests . apiKey, networkSession: networkSession)
222
+ IterableAPI . email = IterableInAppNotificationTests . email
223
+ networkSession. callback = { ( _, _, _) in
224
+ TestUtils . validate ( request: networkSession. request!,
225
+ requestType: . post,
226
+ apiEndPoint: . ITBL_ENDPOINT_API,
227
+ path: . ITBL_PATH_TRACK_INAPP_OPEN,
228
+ queryParams: [ ( name: AnyHashable . ITBL_KEY_API_KEY, value: IterableInAppNotificationTests . apiKey) ,
229
+ ] )
230
+ let body = networkSession. getRequestBody ( ) as! [ String : Any ]
231
+ TestUtils . validateMatch ( keyPath: KeyPath ( AnyHashable . ITBL_KEY_MESSAGE_ID) , value: messageId, inDictionary: body)
232
+ TestUtils . validateMatch ( keyPath: KeyPath ( AnyHashable . ITBL_KEY_EMAIL) , value: IterableInAppNotificationTests . email, inDictionary: body)
233
+ expectation1. fulfill ( )
234
+ }
235
+ IterableAPI . track ( inAppOpen: messageId)
236
+ wait ( for: [ expectation1] , timeout: testExpectationTimeout)
237
+ }
238
+
214
239
private static let apiKey = " zeeApiKey "
215
240
private static let email = " [email protected] "
241
+ private static let userId = " userId1 "
216
242
}
0 commit comments