Skip to content

Commit 7b5c935

Browse files
One more test.
1 parent ddec36a commit 7b5c935

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

Tests/swift-sdk-swift-tests/IterableInAppNotificationTests.swift

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ class IterableInAppNotificationTests: XCTestCase {
166166
func testTrackInAppClickWithButtonUrl() {
167167
let messageId = "message1"
168168
let buttonUrl = "http://somewhere.com"
169-
let expectation1 = expectation(description: "track in app messages")
169+
let expectation1 = expectation(description: "track in app click")
170170

171171
let networkSession = MockNetworkSession(statusCode: 200)
172172
IterableAPI.initialize(apiKey: IterableInAppNotificationTests.apiKey, networkSession: networkSession)
173-
IterableAPI.email = IterableInAppNotificationTests.email
173+
IterableAPI.userId = IterableInAppNotificationTests.userId
174174
networkSession.callback = {(_, _, _) in
175175
TestUtils.validate(request: networkSession.request!,
176176
requestType: .post,
@@ -181,6 +181,7 @@ class IterableInAppNotificationTests: XCTestCase {
181181
let body = networkSession.getRequestBody() as! [String : Any]
182182
TestUtils.validateMatch(keyPath: KeyPath("messageId"), value: messageId, inDictionary: body)
183183
TestUtils.validateMatch(keyPath: KeyPath("urlClick"), value: buttonUrl, inDictionary: body)
184+
TestUtils.validateMatch(keyPath: KeyPath("userId"), value: IterableInAppNotificationTests.userId, inDictionary: body)
184185
expectation1.fulfill()
185186
}
186187
IterableAPI.track(inAppClick: messageId, buttonURL: buttonUrl)
@@ -190,7 +191,7 @@ class IterableInAppNotificationTests: XCTestCase {
190191
func testTrackInAppClickWithButtonIndex() {
191192
let messageId = "message1"
192193
let buttonIndex = "1"
193-
let expectation1 = expectation(description: "track in app messages")
194+
let expectation1 = expectation(description: "track in app click")
194195

195196
let networkSession = MockNetworkSession(statusCode: 200)
196197
IterableAPI.initialize(apiKey: IterableInAppNotificationTests.apiKey, networkSession: networkSession)
@@ -205,12 +206,37 @@ class IterableInAppNotificationTests: XCTestCase {
205206
let body = networkSession.getRequestBody() as! [String : Any]
206207
TestUtils.validateMatch(keyPath: KeyPath("messageId"), value: messageId, inDictionary: body)
207208
TestUtils.validateMatch(keyPath: KeyPath("buttonIndex"), value: buttonIndex, inDictionary: body)
209+
TestUtils.validateMatch(keyPath: KeyPath("email"), value: IterableInAppNotificationTests.email, inDictionary: body)
208210
expectation1.fulfill()
209211
}
210212
IterableAPI.track(inAppClick: messageId, buttonIndex: buttonIndex)
211213
wait(for: [expectation1], timeout: testExpectationTimeout)
212214
}
213215

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+
214239
private static let apiKey = "zeeApiKey"
215240
private static let email = "[email protected]"
241+
private static let userId = "userId1"
216242
}

0 commit comments

Comments
 (0)