Skip to content

Commit 4e529c8

Browse files
committed
add test for requesting JWT when already logged in
1 parent 98542a2 commit 4e529c8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/swift-sdk-swift-tests/AuthTests.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,32 @@ class AuthTests: XCTestCase {
702702
wait(for: [condition2], timeout: 3)
703703
}
704704

705+
func testAuthTokenRequestingForAlreadyExistingEmail() {
706+
let condition1 = expectation(description: "auth handler didn't get called")
707+
708+
let localStorage = MockLocalStorage()
709+
710+
localStorage.email = AuthTests.email
711+
712+
let config = IterableConfig()
713+
714+
let authDelegate = createAuthDelegate({ handler in
715+
condition1.fulfill()
716+
})
717+
718+
config.authDelegate = authDelegate
719+
720+
let internalAPI = IterableAPIInternal.initializeForTesting(config: config,
721+
localStorage: localStorage)
722+
723+
XCTAssertNotNil(internalAPI.email)
724+
XCTAssertNil(internalAPI.authManager.getAuthToken())
725+
726+
internalAPI.email = AuthTests.email
727+
728+
wait(for: [condition1], timeout: testExpectationTimeout)
729+
}
730+
705731
// MARK: - Private
706732

707733
class DefaultAuthDelegate: IterableAuthDelegate {

0 commit comments

Comments
 (0)