Skip to content

Commit

Permalink
✅ Update tests setPushToken
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaatttt authored and iujames committed Sep 17, 2024
1 parent c62abda commit 6f667c2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class AutoPropertyDecoratorTests: XCTestCase {
XCTAssertEqual([], Set(try XCTUnwrap(decorated.properties).keys).symmetricDifference(expectedPropertyKeys))
let expectedEventAutoPropertyKeys = ["userId", "_deviceModel", "_bundlePackageId", "_lastBrowserLanguage", "_localId", "_appName", "_lastSeenAt", "_updatedAt", "_sdkVersion", "_osVersion", "_operatingSystem", "_deviceType", "_appVersion", "_isAnonymous", "_appBuild", "_sdkName", "_appId", "_sessionPageviews", "_sessionRandomizer", "_sessionId"]
XCTAssertEqual([], Set(try XCTUnwrap(decorated.identityAutoProperties).keys).symmetricDifference(expectedEventAutoPropertyKeys))
let expectedEventDeviceAutoPropertyKeys = ["_deviceId", "_language", "_deviceType", "_appBuild", "_appId", "_operatingSystem", "_bundlePackageId", "_deviceModel", "_appVersion", "_sdkVersion", "_osVersion", "_sdkName", "_appName"]
let expectedEventDeviceAutoPropertyKeys = ["_deviceId", "_language", "_pushToken", "_deviceType", "_appBuild", "_appId", "_operatingSystem", "_bundlePackageId", "_deviceModel", "_appVersion", "_sdkVersion", "_osVersion", "_sdkName", "_appName"]
XCTAssertEqual([], Set(try XCTUnwrap(decorated.deviceAutoProperties).keys).symmetricDifference(expectedEventDeviceAutoPropertyKeys))
}

Expand Down
11 changes: 11 additions & 0 deletions Tests/AppcuesKitTests/AppcuesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,17 @@ class AppcuesTests: XCTestCase {
waitForExpectations(timeout: 1)
}

func testSetPushToken() throws {
// Arrange
let token = "some-token".data(using: .utf8)

// Act
appcues.setPushToken(token)

// Assert
XCTAssertEqual(appcues.storage.pushToken, "736f6d652d746f6b656e")
}

func testDidHandleURL() throws {
// Arrange
appcues.deepLinkHandler.onDidHandleURL = { url -> Bool in
Expand Down
1 change: 1 addition & 0 deletions Tests/AppcuesKitTests/MockAppcues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class MockStorage: DataStoring {
var isAnonymous: Bool = false
var lastContentShownAt: Date?
var userSignature: String?
var pushToken: String?
}

class MockExperienceLoader: ExperienceLoading {
Expand Down
2 changes: 2 additions & 0 deletions Tests/AppcuesKitTests/PublicAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class PublicAPITests: XCTestCase {
print(success, error)
}

appcuesInstance.setPushToken(nil)

appcuesInstance.debug()

appcuesInstance.trackScreens()
Expand Down

0 comments on commit 6f667c2

Please sign in to comment.