@@ -30,15 +30,17 @@ class IterableNotificationResponseTests: XCTestCase {
30
30
dateProvider. currentDate = Date ( )
31
31
}
32
32
33
- private func customActionHandler( fromPromise promise: Promise < String , Error > , inContext context : IterableActionContext ) -> CustomActionHandler {
33
+ private static func customActionHandler( fromPromise promise: Promise < String , Error > ) -> CustomActionHandler {
34
34
return { ( customActionName) in
35
35
promise. resolve ( with: customActionName)
36
36
return true
37
37
}
38
38
}
39
39
40
- private func contextToCustomActionHandler( fromPromise promise: Promise < String , Error > ) -> ( IterableActionContext ) -> CustomActionHandler {
41
- return IterableUtil . curry ( customActionHandler ( fromPromise: inContext: ) ) ( promise)
40
+ private static func contextToCustomActionHandler( fromPromise promise: Promise < String , Error > ) -> ( IterableActionContext ) -> CustomActionHandler {
41
+ return { ( context) in
42
+ customActionHandler ( fromPromise: promise)
43
+ }
42
44
}
43
45
44
46
func testTrackOpenPushWithCustomAction( ) {
@@ -61,22 +63,23 @@ class IterableNotificationResponseTests: XCTestCase {
61
63
62
64
let response = MockNotificationResponse ( userInfo: userInfo, actionIdentifier: UNNotificationDefaultActionIdentifier)
63
65
let pushTracker = MockPushTracker ( )
64
- var calledCustomActionName : String ?
65
- let contextToCustomActionHandler : ( ( IterableActionContext ) -> CustomActionHandler ) = { ( context) in { ( customActionName) in
66
- calledCustomActionName = customActionName
67
- return true
66
+ let promise = Promise < String , Error > ( )
67
+ promise. observe { ( result) in
68
+ switch ( result) {
69
+ case . error( let error) :
70
+ XCTFail ( error. localizedDescription)
71
+ case . value( let customActionName) :
72
+ XCTAssertEqual ( customActionName, " customAction " )
68
73
}
69
74
}
70
-
75
+
71
76
let appIntegration = IterableAppIntegrationInternal ( tracker: pushTracker,
72
77
versionInfo: MockVersionInfo ( version: 10 ) ,
73
78
contextToUrlHandler: nil ,
74
- contextToCustomActionHandler: contextToCustomActionHandler,
79
+ contextToCustomActionHandler: IterableNotificationResponseTests . contextToCustomActionHandler ( fromPromise : promise ) ,
75
80
urlOpener: MockUrlOpener ( ) )
76
81
appIntegration. userNotificationCenter ( nil , didReceive: response, withCompletionHandler: nil )
77
82
78
- XCTAssertEqual ( calledCustomActionName, " customAction " ) ;
79
-
80
83
XCTAssertEqual ( pushTracker. campaignId, 1234 )
81
84
XCTAssertEqual ( pushTracker. templateId, 4321 )
82
85
XCTAssertEqual ( pushTracker. messageId, messageId)
@@ -123,7 +126,7 @@ class IterableNotificationResponseTests: XCTestCase {
123
126
let appIntegration = IterableAppIntegrationInternal ( tracker: pushTracker,
124
127
versionInfo: MockVersionInfo ( version: 10 ) ,
125
128
contextToUrlHandler: nil ,
126
- contextToCustomActionHandler: contextToCustomActionHandler ( fromPromise: promise) ,
129
+ contextToCustomActionHandler: IterableNotificationResponseTests . contextToCustomActionHandler ( fromPromise: promise) ,
127
130
urlOpener: MockUrlOpener ( ) )
128
131
appIntegration. userNotificationCenter ( nil , didReceive: response, withCompletionHandler: nil )
129
132
@@ -163,7 +166,7 @@ class IterableNotificationResponseTests: XCTestCase {
163
166
let appIntegration = IterableAppIntegrationInternal ( tracker: pushTracker,
164
167
versionInfo: MockVersionInfo ( version: 9 ) ,
165
168
contextToUrlHandler: nil ,
166
- contextToCustomActionHandler: contextToCustomActionHandler ( fromPromise: promise) ,
169
+ contextToCustomActionHandler: IterableNotificationResponseTests . contextToCustomActionHandler ( fromPromise: promise) ,
167
170
urlOpener: MockUrlOpener ( ) )
168
171
appIntegration. application ( MockApplicationStateProvider ( applicationState: . inactive) , didReceiveRemoteNotification: userInfo, fetchCompletionHandler: nil )
169
172
0 commit comments