@@ -54,6 +54,11 @@ class NotificationCenterTests: XCTestCase {
54
54
notificationCenter. sendNotifications ( type: NotificationType . Track. rawValue, args: [ " eventKey " , " userId " , nil , nil , [ " url " : " https://url.com/ " , " body " : Data ( ) ] ] )
55
55
56
56
}
57
+
58
+ func sendDecision( ) {
59
+ notificationCenter. sendNotifications ( type: NotificationType . Decision. rawValue, args: [ Constants . NotificationKeys. OptimizelyDecisionTypeIsFeatureEnabled, " userId " , nil , [ " url " : " https://url.com/ " , " body " : Data ( ) ] ] )
60
+
61
+ }
57
62
58
63
func sendDatafileChange( ) {
59
64
notificationCenter. sendNotifications ( type: NotificationType . DatafileChange. rawValue, args: [ Data ( ) ] )
@@ -133,6 +138,40 @@ class NotificationCenterTests: XCTestCase {
133
138
XCTAssertTrue ( called)
134
139
}
135
140
141
+ func testNotificationCenterAddRemoveDecision( ) {
142
+ // This is an example of a functional test case.
143
+ // Use XCTAssert and related functions to verify your tests produce the correct results.
144
+ var called = false
145
+
146
+ let _ = notificationCenter. addDecisionNotificationListener { ( type, userId, attr, decisionInfo) in
147
+ called = true
148
+ }
149
+
150
+ notificationCenter. clearNotificationListeners ( type: . Decision)
151
+
152
+ sendDecision ( )
153
+
154
+ XCTAssertFalse ( called)
155
+
156
+ let id = notificationCenter. addDecisionNotificationListener { ( type, userId, attr, decisionInfo) in
157
+ called = true
158
+ }
159
+
160
+ notificationCenter. removeNotificationListener ( notificationId: id!)
161
+
162
+ sendDecision ( )
163
+
164
+ XCTAssertFalse ( called)
165
+
166
+ let _ = notificationCenter. addDecisionNotificationListener { ( type, userId, attr, decisionInfo) in
167
+ called = true
168
+ }
169
+
170
+ sendDecision ( )
171
+
172
+ XCTAssertTrue ( called)
173
+ }
174
+
136
175
func testNotificationCenterAddRemoveDatafileChange( ) {
137
176
// This is an example of a functional test case.
138
177
// Use XCTAssert and related functions to verify your tests produce the correct results.
0 commit comments