File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public enum PrettyDictionary {
17
17
///
18
18
/// - Parameter dictionary: `Dictionary` to be prettified
19
19
/// - Returns: `JSON` string
20
- public static func prettify( _ dictionary: [ String : Any ] ? ) -> String {
20
+ public static func prettify( _ dictionary: [ String : Any ? ] ? ) -> String {
21
21
guard let dictionary = dictionary else {
22
22
return " "
23
23
}
Original file line number Diff line number Diff line change @@ -41,6 +41,33 @@ class PrettyDictionaryTests: XCTestCase {
41
41
XCTAssert ( output. contains ( " AEPServices.LogLevel " ) )
42
42
}
43
43
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
+
44
71
func testPrintEventData_with_prettifiedJsonString( ) throws {
45
72
var eventData = [ String: Any] ( )
46
73
eventData = [
You can’t perform that action at this time.
0 commit comments