Skip to content

Commit

Permalink
✅ Update mock API
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaatttt committed May 6, 2024
1 parent 1b86cfa commit 1c17330
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ class AppcuesRequestPushActionTests: XCTestCase {

func testExecute() throws {
// Arrange
var eventCount = 0
var refreshCount = 0
var completionCount = 0
let action = AppcuesRequestPushAction(appcues: appcues)

appcues.analyticsPublisher.onPublish = { update in
XCTAssertEqual(update.type, .event(name: Events.Device.deviceUpdated.rawValue, interactive: false))
eventCount += 1
appcues.pushMonitor.onRefreshPushStatus = { shouldPublish in
XCTAssertTrue(shouldPublish)
refreshCount += 1
}

// Act
action?.execute(completion: { completionCount += 1 })

// Assert
XCTAssertEqual(eventCount, 1)
XCTAssertEqual(refreshCount, 1)
XCTAssertEqual(completionCount, 1)
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/AppcuesKitTests/MockAppcues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,9 @@ class MockPushMonitor: PushMonitoring {
var pushPrimerEligible: Bool = false

var pushAuthorizationStatus: UNAuthorizationStatus = .notDetermined
var onRefreshPushStatus: (() -> Void)?
func refreshPushStatus(completion: ((UNAuthorizationStatus) -> Void)?) {
onRefreshPushStatus?()
var onRefreshPushStatus: ((Bool) -> Void)?
func refreshPushStatus(publishChange: Bool, completion: ((UNAuthorizationStatus) -> Void)?) {
onRefreshPushStatus?(publishChange)
completion?(pushAuthorizationStatus)
}

Expand Down

0 comments on commit 1c17330

Please sign in to comment.