Skip to content

Commit 01f2fae

Browse files
committed
replace deprecated code in tests
1 parent a0d983e commit 01f2fae

File tree

3 files changed

+50
-60
lines changed

3 files changed

+50
-60
lines changed

tests/hosting-apps/ui-tests-app/ViewController.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,6 @@ class ViewController: UIViewController {
3131
}
3232
}
3333

34-
// deprecated - will be removed in version 6.3.x or above
35-
@IBAction func showSystemNotificationTap(_: UIButton) {
36-
ITBInfo()
37-
38-
IterableAPI.internalImplementation?.showSystemNotification(withTitle: "Zee Title", body: "Zee Body", buttonLeft: "Left Button", buttonRight: "Right Button") { str in
39-
self.statusLbl.text = str
40-
}
41-
}
42-
43-
// deprecated - will be removed in version 6.3.x or above
44-
@IBAction func showSystemNotification2Tap(_: UIButton) {
45-
ITBInfo()
46-
47-
IterableAPI.internalImplementation?.showSystemNotification(withTitle: "Zee Title", body: "Zee Body", buttonLeft: "Zee Button") { str in
48-
self.statusLbl.text = str
49-
}
50-
}
51-
5234
@IBAction func showInAppTap(_: UIButton) {
5335
ITBInfo()
5436

tests/offline-events-tests/RequestHandlerTests.swift

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,14 @@ class RequestHandlerTests: XCTestCase {
551551

552552
let expectations = createExpectations(description: #function)
553553

554-
let requestGenerator = { (requestHandler: RequestHandlerProtocol) in
555-
requestHandler.trackInAppOpen(messageId,
554+
let requestGenerator = { (requestHandler: RequestHandlerProtocol) -> Future<SendRequestValue, SendRequestError> in
555+
let message = IterableInAppMessage(messageId: messageId,
556+
campaignId: nil,
557+
content: IterableHtmlInAppContent(edgeInsets: .zero, html: ""))
558+
559+
return requestHandler.trackInAppOpen(message,
560+
location: .inApp,
561+
inboxSessionId: nil,
556562
onSuccess: expectations.onSuccess,
557563
onFailure: expectations.onFailure)
558564
}
@@ -581,8 +587,14 @@ class RequestHandlerTests: XCTestCase {
581587

582588
let expectations = createExpectations(description: #function)
583589

584-
let requestGenerator = { (requestHandler: RequestHandlerProtocol) in
585-
requestHandler.trackInAppClick(messageId,
590+
let requestGenerator = { (requestHandler: RequestHandlerProtocol) -> Future<SendRequestValue, SendRequestError> in
591+
let message = IterableInAppMessage(messageId: messageId,
592+
campaignId: nil,
593+
content: IterableHtmlInAppContent(edgeInsets: .zero, html: ""))
594+
595+
return requestHandler.trackInAppClick(message,
596+
location: .inApp,
597+
inboxSessionId: nil,
586598
clickedUrl: clickedUrl,
587599
onSuccess: expectations.onSuccess,
588600
onFailure: expectations.onFailure)

tests/unit-tests/DeepLinkTests.swift

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,42 @@ class DeepLinkTests: XCTestCase {
3232

3333
setupRedirectStubResponse(location: redirectLocation, campaignId: campaignId, templateId: templateId, messageId: messageId)
3434

35-
let internalAPI = InternalIterableAPI.initializeForTesting()
36-
37-
internalAPI.getAndTrack(deepLink: URL(string: iterableRewriteURL)!) { redirectUrl in
38-
XCTAssertEqual(redirectUrl, redirectLocation)
35+
let mockUrlDelegate = MockUrlDelegate(returnValue: true)
36+
mockUrlDelegate.callback = { url, context in
37+
XCTAssertEqual(url.absoluteString, redirectLocation)
3938
XCTAssertTrue(Thread.isMainThread)
39+
XCTAssertEqual(context.action.type, IterableAction.actionTypeOpenUrl)
4040
expectation1.fulfill()
4141
}
4242

43+
let deepLinkManager = IterableDeepLinkManager()
44+
45+
_ = deepLinkManager.handleUniversalLink(URL(string: iterableRewriteURL)!,
46+
urlDelegate: mockUrlDelegate,
47+
urlOpener: MockUrlOpener())
48+
4349
wait(for: [expectation1], timeout: testExpectationTimeout)
4450
}
4551

4652
func testTrackUniversalDeepLinkNoRewrite() {
4753
let expectation1 = expectation(description: "testUniversalDeepLinkNoRewrite")
4854

4955
setupStubResponse()
50-
51-
let internalAPI = InternalIterableAPI.initializeForTesting()
52-
internalAPI.getAndTrack(deepLink: URL(string: iterableNoRewriteURL)!) { redirectUrl in
53-
XCTAssertEqual(redirectUrl, self.iterableNoRewriteURL)
56+
57+
let mockUrlDelegate = MockUrlDelegate(returnValue: true)
58+
mockUrlDelegate.callback = { url, context in
59+
XCTAssertEqual(url.absoluteString, self.iterableNoRewriteURL)
5460
XCTAssertTrue(Thread.isMainThread)
61+
XCTAssertEqual(context.action.type, IterableAction.actionTypeOpenUrl)
5562
expectation1.fulfill()
5663
}
5764

65+
let deepLinkManager = IterableDeepLinkManager()
66+
67+
_ = deepLinkManager.handleUniversalLink(URL(string: iterableNoRewriteURL)!,
68+
urlDelegate: mockUrlDelegate,
69+
urlOpener: MockUrlOpener())
70+
5871
wait(for: [expectation1], timeout: testExpectationTimeout)
5972
}
6073

@@ -84,31 +97,8 @@ class DeepLinkTests: XCTestCase {
8497
wait(for: [expectation1], timeout: testExpectationTimeout)
8598
}
8699

87-
func testDeeplinkAttributionInfo() {
88-
let expectation1 = expectation(description: "testDeeplinkAttributionInfo")
89-
90-
let redirectLocation = "https://links.iterable.com/api/docs#!/email"
91-
let campaignId = 83306
92-
let templateId = 124_348
93-
let messageId = "93125f33ba814b13a882358f8e0852e0"
94-
95-
setupRedirectStubResponse(location: redirectLocation, campaignId: campaignId, templateId: templateId, messageId: messageId)
96-
97-
let internalAPI = InternalIterableAPI.initializeForTesting()
98-
internalAPI.getAndTrack(deepLink: URL(string: iterableRewriteURL)!) { resolvedURL in
99-
XCTAssertEqual(resolvedURL, redirectLocation)
100-
}?.onSuccess(block: { _ in
101-
XCTAssertEqual(internalAPI.attributionInfo?.campaignId, NSNumber(value: campaignId))
102-
XCTAssertEqual(internalAPI.attributionInfo?.templateId, NSNumber(value: templateId))
103-
XCTAssertEqual(internalAPI.attributionInfo?.messageId, messageId)
104-
expectation1.fulfill()
105-
})
106-
107-
wait(for: [expectation1], timeout: testExpectationTimeout)
108-
}
109-
110100
func testHandleUniversalLinkAttributionInfo() {
111-
let expectation1 = expectation(description: "testDeeplinkAttributionInfo")
101+
let expectation1 = expectation(description: "testHandleUniversalLinkAttributionInfo")
112102

113103
let redirectLocation = "https://links.iterable.com/api/docs#!/email"
114104
let campaignId = 83306
@@ -130,20 +120,26 @@ class DeepLinkTests: XCTestCase {
130120
wait(for: [expectation1], timeout: testExpectationTimeout)
131121
}
132122

133-
// this is a service that automatically redirects if that url is hit, make sure we are not actually hitting the url
134-
// but our servers
123+
/// this is a service that automatically redirects if that url is hit, make sure we are not actually hitting the url but our servers
135124
func testNoURLRedirect() {
136125
let expectation1 = expectation(description: "testNoURLRedirect")
137126

138127
setupStubResponse()
139128

140-
let internalAPI = InternalIterableAPI.initializeForTesting()
141-
internalAPI.getAndTrack(deepLink: URL(string: redirectRequest)!) { redirectUrl in
142-
XCTAssertNotEqual(redirectUrl, self.exampleUrl)
143-
XCTAssertEqual(redirectUrl, self.redirectRequest)
129+
let mockUrlDelegate = MockUrlDelegate(returnValue: false)
130+
mockUrlDelegate.callback = { redirectUrl, context in
131+
XCTAssertNotEqual(redirectUrl.absoluteString, self.exampleUrl)
132+
XCTAssertEqual(redirectUrl.absoluteString, self.redirectRequest)
133+
144134
expectation1.fulfill()
145135
}
146136

137+
let deepLinkManager = IterableDeepLinkManager()
138+
139+
_ = deepLinkManager.handleUniversalLink(URL(string: redirectRequest)!,
140+
urlDelegate: mockUrlDelegate,
141+
urlOpener: MockUrlOpener())
142+
147143
wait(for: [expectation1], timeout: testExpectationTimeout)
148144
}
149145

0 commit comments

Comments
 (0)