@@ -101,8 +101,8 @@ class IterableAPITests: XCTestCase {
101
101
wait ( for: [ expectation] , timeout: testExpectationTimeout)
102
102
}
103
103
104
- func testUpdateUser ( ) {
105
- let expectation = XCTestExpectation ( description: " testUpdateUser " )
104
+ func testUpdateUserWithEmail ( ) {
105
+ let expectation = XCTestExpectation ( description: " testUpdateUserWithEmail " )
106
106
107
107
let networkSession = MockNetworkSession ( statusCode: 200 )
108
108
IterableAPI . initialize ( apiKey: IterableAPITests . apiKey, networkSession: networkSession)
@@ -127,6 +127,34 @@ class IterableAPITests: XCTestCase {
127
127
wait ( for: [ expectation] , timeout: testExpectationTimeout)
128
128
}
129
129
130
+ func testUpdateUserWithUserId( ) {
131
+ let expectation = XCTestExpectation ( description: " testUpdateUserWithUserId " )
132
+
133
+ let userId = UUID ( ) . uuidString
134
+ let networkSession = MockNetworkSession ( statusCode: 200 )
135
+ IterableAPI . initialize ( apiKey: IterableAPITests . apiKey, networkSession: networkSession)
136
+ IterableAPI . userId = userId
137
+ let dataFields : Dictionary < String , String > = [ " var1 " : " val1 " , " var2 " : " val2 " ]
138
+ IterableAPI . updateUser ( dataFields, mergeNestedObjects: true , onSuccess: { ( json) in
139
+ TestUtils . validate ( request: networkSession. request!, requestType: . post, apiEndPoint: . ITBL_ENDPOINT_API, path: . ITBL_PATH_UPDATE_USER, queryParams: [ ( name: " api_key " , IterableAPITests . apiKey) ] )
140
+ let body = networkSession. getRequestBody ( )
141
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_USER_ID, andValue: userId, inDictionary: body)
142
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_PREFER_USER_ID, andValue: true , inDictionary: body)
143
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_MERGE_NESTED, andValue: true , inDictionary: body)
144
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_DATA_FIELDS, andValue: dataFields, inDictionary: body)
145
+ expectation. fulfill ( )
146
+ } ) { ( reason, _) in
147
+ if let reason = reason {
148
+ XCTFail ( " encountered error: \( reason) " )
149
+ } else {
150
+ XCTFail ( " encountered error " )
151
+ }
152
+ expectation. fulfill ( )
153
+ }
154
+
155
+ wait ( for: [ expectation] , timeout: testExpectationTimeout)
156
+ }
157
+
130
158
func testUpdateEmail( ) {
131
159
let expectation = XCTestExpectation ( description: " testUpdateEmail " )
132
160
0 commit comments