Skip to content

Commit fe95291

Browse files
wip: update test cases
1 parent 424e2f9 commit fe95291

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

Tests/OptimizelyTests-Common/BatchEventBuilderTests_EventTags.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class BatchEventBuilderTests_EventTags: XCTestCase {
7676

7777
extension BatchEventBuilderTests_EventTags {
7878

79-
func testEventTagsWhenInvalidType() {
79+
func testEventTagsWhenArrayType() {
8080
let eventKey = "event_single_targeted_exp"
8181
let eventTags: [String: Any] = ["browser": "chrome",
8282
"future": [1, 2, 3]]
@@ -87,7 +87,8 @@ extension BatchEventBuilderTests_EventTags {
8787
let tags = de["tags"] as! [String: Any]
8888

8989
XCTAssertEqual(tags["browser"] as! String, "chrome")
90-
XCTAssertNil(tags["future"])
90+
XCTAssertNotNil(tags["future"])
91+
XCTAssertEqual(tags["future"] as? [Int], [1, 2, 3])
9192
}
9293

9394
func testEventTagsWhenTooBigNumbers() {

Tests/OptimizelyTests-DataModel/AttributeValueTests.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,20 @@ class AttributeValueTests: XCTestCase {
137137
XCTAssertEqual(model, model2)
138138
}
139139

140+
func testEncodeDecodeWithDictionaryType() {
141+
let value: [String: Any] = [
142+
"string": "stringvalue",
143+
"double": 13.0,
144+
"bool": true,
145+
"array": ["a", "b", "c"]
146+
]
147+
let model = AttributeValue(value: value)
148+
149+
let encoded = try! OTUtils.getAttributeValueFromNative(value)
150+
print("hello")
151+
XCTAssertEqual(encoded, model)
152+
}
153+
140154
func testDecodeSuccessWithInvalidTypeNil() {
141155
let anyNil: Any? = nil
142156
let model = try! OTUtils.getAttributeValueFromNative(anyNil)

Tests/OptimizelyTests-DataModel/UserAttributeTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ extension UserAttributeTests {
116116
XCTAssert(model.matchSupported == .exact)
117117
}
118118

119-
func testDecodeSuccessWithWrongValueType() {
119+
func testDecodeSuccessWithArrayValueType() {
120120
let json: [String: Any] = ["name": "geo", "type": "custom_attribute", "match": "exact", "value": ["a1", "a2"]]
121121
let jsonData = try! JSONSerialization.data(withJSONObject: json, options: [])
122122
let model = try! JSONDecoder().decode(modelType, from: jsonData)
123123

124124
XCTAssert(model.name == "geo")
125125
XCTAssert(model.typeSupported == .customAttribute)
126126
XCTAssert(model.matchSupported == .exact)
127-
XCTAssert(model.value == .others)
127+
XCTAssert(model.value == AttributeValue(value: ["a1", "a2"]))
128128
}
129129

130130
// MARK: - Forward Compatibility

0 commit comments

Comments
 (0)