Skip to content

Commit 99a0f65

Browse files
wip: test case updated
1 parent 478ecb6 commit 99a0f65

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Sources/Data Model/Audience/AttributeValue.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ enum AttributeValue: Codable, Equatable, CustomStringConvertible {
118118
}
119119

120120

121-
// accept all other types (null, {}, []) for forward compatibility support
121+
// accept all other types (null) for forward compatibility support
122122
self = .others
123123
}
124124

@@ -321,6 +321,7 @@ extension AttributeValue {
321321
case (.double): return true
322322
case (.bool): return true
323323
case (.array): return true
324+
case (.dictionary): return true
324325
default: return false
325326
}
326327
}

Tests/OptimizelyTests-Common/BatchEventBuilderTests_EventTags.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,12 @@ extension BatchEventBuilderTests_EventTags {
324324
"Text": "value",
325325
"nested": [
326326
"foot": "value",
327-
"mouch": "valuefalsdf"
328-
]
327+
"mouth": "mouth_value"
328+
],
329+
"stringArray": ["a", "b", "c"],
330+
"intArray": [1, 2, 3],
331+
"doubleArray": [1.0, 2.0, 3.0],
332+
"boolAray": [false, true, false, true],
329333
]
330334
let eventKey = "event_single_targeted_exp"
331335
let eventTags: [String: Any] = ["browser": "chrome",
@@ -350,6 +354,14 @@ extension BatchEventBuilderTests_EventTags {
350354
XCTAssertEqual(de["revenue"] as! Int, 40, "value must be valid for revenue")
351355
XCTAssertEqual(de["value"] as! Double, 32, "value must be valid for value")
352356

357+
XCTAssertEqual((tags["$opt_event_properties"] as! [String : Any])["category"] as! String, "shoes")
358+
XCTAssertEqual((tags["$opt_event_properties"] as! [String : Any])["nested"] as! [String : String], ["foot": "value", "mouth": "mouth_value"])
359+
360+
XCTAssertEqual((tags["$opt_event_properties"] as! [String : Any])["stringArray"] as! [String], ["a", "b", "c"])
361+
XCTAssertEqual((tags["$opt_event_properties"] as! [String : Any])["intArray"] as! [Int], [1, 2, 3])
362+
XCTAssertEqual((tags["$opt_event_properties"] as! [String : Any])["doubleArray"] as! [Double], [1, 2, 3])
363+
XCTAssertEqual((tags["$opt_event_properties"] as! [String : Any])["boolAray"] as! [Bool], [false, true, false, true])
364+
353365

354366
}
355367

0 commit comments

Comments
 (0)