Skip to content

Commit

Permalink
✅ Update device prop tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaatttt authored and iujames committed Sep 17, 2024
1 parent 98c5ade commit 568b9fd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class AppcuesRequestPushActionTests: XCTestCase {
var completionCount = 0
let action = AppcuesRequestPushAction(appcues: appcues)

appcues.pushMonitor.onRefreshPushStatus = { shouldPublish in
XCTAssertTrue(shouldPublish)
appcues.pushMonitor.onRefreshPushStatus = {
refreshCount += 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 @@ -397,9 +397,9 @@ class MockPushMonitor: PushMonitoring {
onSetPushToken?(deviceToken)
}

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

Expand Down
18 changes: 18 additions & 0 deletions Tests/AppcuesKitTests/Push/PushMonitorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,24 @@ class PushMonitorTests: XCTestCase {
XCTAssertEqual(appcues.storage.pushToken, "736f6d652d746f6b656e")
}

func testSetPushTokenNoAnalyticsWhenSameValue() throws {
// Arrange
appcues.storage.pushToken = "736f6d652d746f6b656e"
appcues.sessionID = UUID()
let token = "some-token".data(using: .utf8)
let eventExpectation = expectation(description: "Device event logged")
eventExpectation.isInverted = true
appcues.analyticsPublisher.onPublish = { trackingUpdate in
eventExpectation.fulfill()
}

// Act
pushMonitor.setPushToken(token)

// Assert
waitForExpectations(timeout: 1)
XCTAssertEqual(appcues.storage.pushToken, "736f6d652d746f6b656e")
}
// MARK: Receive Handler

func testReceiveActiveSession() throws {
Expand Down

0 comments on commit 568b9fd

Please sign in to comment.