Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alfogrillo committed Jul 12, 2023
1 parent 14e6855 commit 8c88395
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,35 +180,39 @@ final class NotificationManagerTests: XCTestCase {

func test_MessageNotificationsRemoval() async throws {
let notificationPublisher = NotificationCenter.default.publisher(for: .roomMarkedAsRead).first()
var cancellables: Set<AnyCancellable> = .init()
let expectation1 = expectation(description: #function)
let subscription1 = notificationPublisher
notificationPublisher
.sink { _ in
expectation1.fulfill()
}

.store(in: &cancellables)

// No interaction if the object is nil or of the wrong type
NotificationCenter.default.post(name: .roomMarkedAsRead, object: nil)
await fulfillment(of: [expectation1])
XCTAssertEqual(notificationCenter.deliveredNotificationsCallsCount, 0)
XCTAssertEqual(notificationCenter.removeDeliveredNotificationsCallsCount, 0)

let expectation2 = expectation(description: #function)
let subscription2 = notificationPublisher
notificationPublisher
.sink { _ in
expectation2.fulfill()
}

.store(in: &cancellables)

NotificationCenter.default.post(name: .roomMarkedAsRead, object: 1)
await fulfillment(of: [expectation2])
XCTAssertEqual(notificationCenter.deliveredNotificationsCallsCount, 0)
XCTAssertEqual(notificationCenter.removeDeliveredNotificationsCallsCount, 0)

let expectation3 = expectation(description: #function)
let subscription3 = notificationPublisher
notificationPublisher
.sink { _ in
expectation3.fulfill()
}

.store(in: &cancellables)

// The center calls the delivered and the removal functions when an id is passed
NotificationCenter.default.post(name: .roomMarkedAsRead, object: "RoomID")
await fulfillment(of: [expectation3])
Expand Down

0 comments on commit 8c88395

Please sign in to comment.