-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #540 from Iterable/jay/MOB-4239-updateEmail-withToken
[MOB-4239] fix update email with token
- Loading branch information
Showing
5 changed files
with
72 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,7 +90,7 @@ class AuthTests: XCTestCase { | |
XCTAssertNil(internalAPI.auth.authToken) | ||
} | ||
|
||
func testNewEmailWithTokenChange() { | ||
func testNewEmailAndThenChangeToken() { | ||
var internalAPI: InternalIterableAPI? | ||
|
||
let originalEmail = "[email protected]" | ||
|
@@ -128,7 +128,7 @@ class AuthTests: XCTestCase { | |
XCTAssertEqual(API.auth.authToken, newToken) | ||
} | ||
|
||
func testNewUserIdWithTokenChange() { | ||
func testNewUserIdAndThenChangeToken() { | ||
var internalAPI: InternalIterableAPI? | ||
|
||
let originalUserId = "firstUserId" | ||
|
@@ -166,8 +166,8 @@ class AuthTests: XCTestCase { | |
XCTAssertEqual(API.auth.authToken, newToken) | ||
} | ||
|
||
func testUpdateEmailWithToken() { | ||
let condition1 = expectation(description: "update email with auth token") | ||
func testUpdateEmailAndThenChangeToken() { | ||
let condition1 = expectation(description: "update email and then change auth token") | ||
|
||
var internalAPI: InternalIterableAPI? | ||
|
||
|
@@ -211,6 +211,50 @@ class AuthTests: XCTestCase { | |
wait(for: [condition1], timeout: testExpectationTimeout) | ||
} | ||
|
||
func testUpdateEmailWithTokenParam() { | ||
let condition1 = expectation(description: #function) | ||
|
||
var internalAPI: InternalIterableAPI? | ||
|
||
let originalEmail = "rtbo" | ||
let originalToken = "hngk" | ||
|
||
let updatedEmail = "2" | ||
let updatedToken = "564g" | ||
|
||
let authDelegate = DefaultAuthDelegate { | ||
return originalToken | ||
} | ||
|
||
let config = IterableConfig() | ||
config.authDelegate = authDelegate | ||
|
||
internalAPI = InternalIterableAPI.initializeForTesting(config: config) | ||
|
||
guard let API = internalAPI else { | ||
XCTFail() | ||
return | ||
} | ||
|
||
API.setEmail(originalEmail) | ||
|
||
XCTAssertEqual(API.email, originalEmail) | ||
XCTAssertNil(API.userId) | ||
XCTAssertEqual(API.auth.authToken, originalToken) | ||
|
||
API.updateEmail(updatedEmail, withToken: updatedToken) { data in | ||
XCTAssertEqual(API.email, updatedEmail) | ||
XCTAssertNil(API.userId) | ||
XCTAssertEqual(API.auth.authToken, updatedToken) | ||
|
||
condition1.fulfill() | ||
} onFailure: { reason, data in | ||
XCTFail() | ||
} | ||
|
||
wait(for: [condition1], timeout: testExpectationTimeout) | ||
} | ||
|
||
func testLogoutUser() { | ||
let authDelegate = createStockAuthDelegate() | ||
|
||
|