@@ -614,7 +614,7 @@ class AuthTests: XCTestCase {
614614 onSuccess: { token in
615615 XCTAssertEqual ( token, AuthTests . authToken)
616616 condition1. fulfill ( )
617- } )
617+ } )
618618
619619 wait ( for: [ condition1] , timeout: testExpectationTimeout)
620620 }
@@ -665,6 +665,44 @@ class AuthTests: XCTestCase {
665665 wait ( for: [ condition2] , timeout: testExpectationTimeoutForInverted)
666666 }
667667
668+ func testRefreshTimerQueueRejection( ) {
669+ let condition1 = expectation ( description: " \( #function) - first refresh timer never happened called " )
670+ let condition2 = expectation ( description: " \( #function) - second refresh timer should not have been called " )
671+ condition2. isInverted = true
672+
673+ class AsyncAuthDelegate : IterableAuthDelegate {
674+ func onAuthTokenRequested( completion: @escaping AuthTokenRetrievalHandler ) {
675+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + 3 ) {
676+ completion ( AuthTests . authToken)
677+ }
678+ }
679+ }
680+
681+ let authDelegate = AsyncAuthDelegate ( )
682+
683+ let config = IterableConfig ( )
684+ config. authDelegate = authDelegate
685+
686+ let authManager = AuthManager ( delegate: config. authDelegate,
687+ expirationRefreshPeriod: config. expiringAuthTokenRefreshPeriod,
688+ localStorage: MockLocalStorage ( ) ,
689+ dateProvider: MockDateProvider ( ) )
690+
691+ authManager. requestNewAuthToken ( hasFailedPriorAuth: false ,
692+ onSuccess: { token in
693+ XCTAssertEqual ( token, AuthTests . authToken)
694+ condition1. fulfill ( )
695+ } )
696+
697+ authManager. requestNewAuthToken ( hasFailedPriorAuth: false ,
698+ onSuccess: { token in
699+ condition2. fulfill ( )
700+ } )
701+
702+ wait ( for: [ condition1] , timeout: testExpectationTimeout)
703+ wait ( for: [ condition2] , timeout: 3 )
704+ }
705+
668706 // MARK: - Private
669707
670708 class DefaultAuthDelegate : IterableAuthDelegate {
0 commit comments