@@ -127,8 +127,8 @@ class IterableAPITests: XCTestCase {
127
127
wait ( for: [ expectation] , timeout: testExpectationTimeout)
128
128
}
129
129
130
- func testUpdateEmail ( ) {
131
- let expectation = XCTestExpectation ( description: " testUpdateEmail " )
130
+ func testUpdateEmailWithEmail ( ) {
131
+ let expectation = XCTestExpectation ( description: " testUpdateEmailWithEmail " )
132
132
133
133
let newEmail = " [email protected] "
134
134
let networkSession = MockNetworkSession ( statusCode: 200 )
@@ -158,6 +158,40 @@ class IterableAPITests: XCTestCase {
158
158
159
159
wait ( for: [ expectation] , timeout: testExpectationTimeout)
160
160
}
161
+
162
+ func testUpdateEmailWithUserId( ) {
163
+ let expectation = XCTestExpectation ( description: " testUpdateEmailWithUserId " )
164
+
165
+ let currentUserId = IterableUtil . generateUUID ( )
166
+ let newEmail = " [email protected] "
167
+ let networkSession = MockNetworkSession ( statusCode: 200 )
168
+ IterableAPI . initializeForTesting ( apiKey: IterableAPITests . apiKey, networkSession: networkSession)
169
+ IterableAPI . userId = currentUserId
170
+ IterableAPI . updateEmail ( newEmail,
171
+ onSuccess: { json in
172
+ TestUtils . validate ( request: networkSession. request!,
173
+ requestType: . post,
174
+ apiEndPoint: . ITBL_ENDPOINT_API,
175
+ path: . ITBL_PATH_UPDATE_EMAIL,
176
+ queryParams: [ ( name: " api_key " , value: IterableAPITests . apiKey) ] )
177
+ let body = networkSession. getRequestBody ( )
178
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_NEW_EMAIL, andValue: newEmail, inDictionary: body)
179
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_CURRENT_USER_ID, andValue: currentUserId, inDictionary: body)
180
+ XCTAssertEqual ( IterableAPI . email, newEmail)
181
+ expectation. fulfill ( )
182
+ } ,
183
+ onFailure: { ( reason, _) in
184
+ expectation. fulfill ( )
185
+ if let reason = reason {
186
+ XCTFail ( " encountered error: \( reason) " )
187
+ } else {
188
+ XCTFail ( " encountered error " )
189
+ }
190
+ } )
191
+
192
+ wait ( for: [ expectation] , timeout: testExpectationTimeout)
193
+ }
194
+
161
195
162
196
func testRegisterTokenNilAppName( ) {
163
197
let expectation = XCTestExpectation ( description: " testRegisterToken " )
0 commit comments