Skip to content

Commit

Permalink
👌 Improve handling of ExperienceData in analytics property comparison…
Browse files Browse the repository at this point in the history
… helpers
  • Loading branch information
iujames committed Jan 6, 2023
1 parent db867eb commit 255be4f
Showing 1 changed file with 5 additions and 34 deletions.
39 changes: 5 additions & 34 deletions Tests/AppcuesKitTests/Analytics/AnalyticsTrackerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,10 @@ extension Dictionary where Key == String, Value == Any {
}
XCTAssertEqual(Set(self.keys), Set(other.keys), file: file, line: line)
self.keys.forEach { key in
if #available(iOS 13.0, *) {
// can reference ExperienceData.StepState on 13+
switch(self[key], other[key]) {
case let (val1 as String, val2 as String):
XCTAssertEqual(val1, val2, file: file, line: line)
case let (val1 as NSNumber, val2 as NSNumber):
XCTAssertEqual(val1, val2, file: file, line: line)
case let (val1 as [Any], val2 as [Any]):
val1.verifyPropertiesMatch(val2, file: file, line: line)
case let (val1 as [String: Any], val2 as [String: Any]):
val1.verifyPropertiesMatch(val2, file: file, line: line)
case let (val1 as ExperienceData.StepState, val2 as ExperienceData.StepState):
XCTAssertEqual(val1, val2, file: file, line: line)
default:
XCTFail("\(self[key] ?? "nil") does not match \(other[key] ?? "nil").", file: file, line: line)
}
// special case since ExperienceData is 13+
if #available(iOS 13.0, *), let val1 = self[key] as? ExperienceData.StepState, let val2 = other[key] as? ExperienceData.StepState {
XCTAssertEqual(val1, val2, file: file, line: line)
} else {
// cannot reference ExperienceData.StepState
switch(self[key], other[key]) {
case let (val1 as String, val2 as String):
XCTAssertEqual(val1, val2, file: file, line: line)
Expand Down Expand Up @@ -143,24 +129,9 @@ extension Array where Element == Any {
XCTAssertEqual(self.count, other.count, file: file, line: line)

zip(self, other).forEach { (selfVal, otherVal) in
if #available(iOS 13.0, *) {
// can reference ExperienceData.StepState on 13+
switch(selfVal, otherVal) {
case let (val1 as String, val2 as String):
XCTAssertEqual(val1, val2, file: file, line: line)
case let (val1 as NSNumber, val2 as NSNumber):
XCTAssertEqual(val1, val2, file: file, line: line)
case let (val1 as [Any], val2 as [Any]):
val1.verifyPropertiesMatch(val2, file: file, line: line)
case let (val1 as [String: Any], val2 as [String: Any]):
val1.verifyPropertiesMatch(val2, file: file, line: line)
case let (val1 as ExperienceData.StepState, val2 as ExperienceData.StepState):
XCTAssertEqual(val1, val2, file: file, line: line)
default:
XCTFail("\(selfVal) does not match \(otherVal).", file: file, line: line)
}
if #available(iOS 13.0, *), let val1 = selfVal as? ExperienceData.StepState, let val2 = otherVal as? ExperienceData.StepState {
XCTAssertEqual(val1, val2, file: file, line: line)
} else {
// cannot reference ExperienceData.StepState
switch(selfVal, otherVal) {
case let (val1 as String, val2 as String):
XCTAssertEqual(val1, val2, file: file, line: line)
Expand Down

0 comments on commit 255be4f

Please sign in to comment.