Skip to content

Commit 2884b50

Browse files
author
Yasir Ali
committed
Test-cases updated.
1 parent f137b52 commit 2884b50

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

OptimizelySDK/OptimizelyTests/OptimizelyTests-Common/NotificationCenterTests.swift

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ class NotificationCenterTests: XCTestCase {
5454
notificationCenter.sendNotifications(type: NotificationType.Track.rawValue, args: ["eventKey", "userId", nil, nil, ["url":"https://url.com/", "body": Data()]])
5555

5656
}
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+
}
5762

5863
func sendDatafileChange() {
5964
notificationCenter.sendNotifications(type: NotificationType.DatafileChange.rawValue, args: [Data()])
@@ -133,6 +138,40 @@ class NotificationCenterTests: XCTestCase {
133138
XCTAssertTrue(called)
134139
}
135140

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+
136175
func testNotificationCenterAddRemoveDatafileChange() {
137176
// This is an example of a functional test case.
138177
// Use XCTAssert and related functions to verify your tests produce the correct results.

0 commit comments

Comments
 (0)