@@ -130,6 +130,69 @@ class ObjC_Tests: XCTestCase {
130
130
XCTAssertTrue ( lastEvent is IdentifyEvent )
131
131
XCTAssertTrue ( ( lastEvent as! IdentifyEvent ) . userId == " batman " )
132
132
}
133
+
134
+ func testObjCDictionaryPassThru( ) {
135
+ Storage . hardSettingsReset ( writeKey: " WRITE_KEY2 " )
136
+
137
+ let config = ObjCConfiguration ( writeKey: " WRITE_KEY2 " )
138
+ let analytics = ObjCAnalytics ( configuration: config)
139
+ analytics. analytics. storage. hardReset ( doYouKnowHowToUseThis: true )
140
+
141
+ analytics. reset ( )
142
+
143
+ let outputReader = OutputReaderPlugin ( )
144
+ analytics. analytics. add ( plugin: outputReader)
145
+
146
+ waitUntilStarted ( analytics: analytics. analytics)
147
+
148
+ let dict = [
149
+ " ancientAliens " : [
150
+ " guy1 " : " hair guy " ,
151
+ " guy2 " : " old mi5 guy " ,
152
+ " guy3 " : " old bald guy " ,
153
+ " guy4 " : 4 ] as [ String : Any ] ,
154
+ " channel " : " hIsToRy cHaNnEL " ] as [ String : Any ]
155
+
156
+ analytics. track ( name: " test " , properties: dict)
157
+ RunLoop . main. run ( until: Date . distantPast)
158
+ let trackEvent = outputReader. lastEvent as? TrackEvent
159
+ let props = trackEvent? . properties? . dictionaryValue
160
+ XCTAssertNotNil ( trackEvent)
161
+ XCTAssertTrue ( props? . count == 2 )
162
+ XCTAssertTrue ( ( props ? [ " ancientAliens " ] as? [ String : Any ] ) ? . count == 4 )
163
+
164
+ analytics. identify ( userId: " test " , traits: dict)
165
+ RunLoop . main. run ( until: Date . distantPast)
166
+ let identifyEvent = outputReader. lastEvent as? IdentifyEvent
167
+ let traits = identifyEvent? . traits? . dictionaryValue
168
+ XCTAssertNotNil ( identifyEvent)
169
+ XCTAssertTrue ( traits? . count == 2 )
170
+ XCTAssertTrue ( ( traits ? [ " ancientAliens " ] as? [ String : Any ] ) ? . count == 4 )
171
+
172
+ analytics. identify ( userId: nil , traits: dict)
173
+ RunLoop . main. run ( until: Date . distantPast)
174
+ let identifyEvent2 = outputReader. lastEvent as? IdentifyEvent
175
+ let traits2 = identifyEvent2? . traits? . dictionaryValue
176
+ XCTAssertNotNil ( identifyEvent2)
177
+ XCTAssertTrue ( traits2? . count == 2 )
178
+ XCTAssertTrue ( ( traits2 ? [ " ancientAliens " ] as? [ String : Any ] ) ? . count == 4 )
179
+
180
+ analytics. screen ( title: " blah " , category: nil , properties: dict)
181
+ RunLoop . main. run ( until: Date . distantPast)
182
+ let screenEvent = outputReader. lastEvent as? ScreenEvent
183
+ let props2 = screenEvent? . properties? . dictionaryValue
184
+ XCTAssertNotNil ( screenEvent)
185
+ XCTAssertTrue ( props2? . count == 2 )
186
+ XCTAssertTrue ( ( props2 ? [ " ancientAliens " ] as? [ String : Any ] ) ? . count == 4 )
187
+
188
+ analytics. group ( groupId: " 123 " , traits: dict)
189
+ RunLoop . main. run ( until: Date . distantPast)
190
+ let groupEvent = outputReader. lastEvent as? GroupEvent
191
+ let traits3 = groupEvent? . traits? . dictionaryValue
192
+ XCTAssertNotNil ( groupEvent)
193
+ XCTAssertTrue ( traits3? . count == 2 )
194
+ XCTAssertTrue ( ( traits3 ? [ " ancientAliens " ] as? [ String : Any ] ) ? . count == 4 )
195
+ }
133
196
}
134
197
135
198
#endif
0 commit comments