Skip to content

Commit d10d894

Browse files
authored
Fix log warnings (adobe#603)
1 parent b2718e8 commit d10d894

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

AEPServices/Sources/utility/PrettyDictionary.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public enum PrettyDictionary {
1717
///
1818
/// - Parameter dictionary: `Dictionary` to be prettified
1919
/// - Returns: `JSON` string
20-
public static func prettify(_ dictionary: [String: Any]?) -> String {
20+
public static func prettify(_ dictionary: [String: Any?]?) -> String {
2121
guard let dictionary = dictionary else {
2222
return ""
2323
}

AEPServices/Tests/utility/PrettyDictionaryTests.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,33 @@ class PrettyDictionaryTests: XCTestCase {
4141
XCTAssert(output.contains("AEPServices.LogLevel"))
4242
}
4343

44+
func testPrintEventData_as_AnyObjectWithNil() throws {
45+
var eventData = [String: Any?]()
46+
eventData = [
47+
"a": "13435454",
48+
"b":[
49+
"b1": 1235566,
50+
"b2": LogLevel.debug
51+
],
52+
"c": nil
53+
]
54+
let output = "\(PrettyDictionary.prettify(eventData))"
55+
let expected = """
56+
{
57+
a = 13435454;
58+
b = {
59+
b1 = 1235566;
60+
b2 = "AEPServices.LogLevel";
61+
};
62+
}
63+
"""
64+
print(output)
65+
print(expected)
66+
XCTAssert(output.contains("13435454;"))
67+
XCTAssert(output.contains("AEPServices.LogLevel"))
68+
XCTAssert(output.contains("null"))
69+
}
70+
4471
func testPrintEventData_with_prettifiedJsonString() throws {
4572
var eventData = [String: Any]()
4673
eventData = [

0 commit comments

Comments
 (0)