17
17
18
18
import {
19
19
AuthError ,
20
+ Persistence ,
20
21
PopupRedirectResolver
21
22
} from '../../model/public_types' ;
22
23
import { OperationType , ProviderId } from '../../model/enums' ;
@@ -32,7 +33,7 @@ import {
32
33
import { makeMockPopupRedirectResolver } from '../../../test/helpers/mock_popup_redirect_resolver' ;
33
34
import { AuthInternal } from '../../model/auth' ;
34
35
import { AuthEventManager } from '../auth/auth_event_manager' ;
35
- import { RedirectAction , _clearRedirectOutcomes } from './redirect' ;
36
+ import { RedirectAction , _clearRedirectOutcomes , _getAndClearPendingRedirectStatus } from './redirect' ;
36
37
import {
37
38
AuthEvent ,
38
39
AuthEventType ,
@@ -44,6 +45,7 @@ import * as idpTasks from '../strategies/idp';
44
45
import { expect , use } from 'chai' ;
45
46
import { AuthErrorCode } from '../errors' ;
46
47
import { RedirectPersistence } from '../../../test/helpers/redirect_persistence' ;
48
+ import { ErroringUnavailablePersistence } from '../../../test/helpers/erroring_unavailable_persistence' ;
47
49
48
50
use ( sinonChai ) ;
49
51
@@ -210,4 +212,26 @@ describe('core/strategies/redirect', () => {
210
212
expect ( await redirectAction . execute ( ) ) . to . eq ( null ) ;
211
213
expect ( resolverInstance . _initialize ) . not . to . have . been . called ;
212
214
} ) ;
215
+
216
+ context ( '_getAndClearPendingRedirectStatus' , ( ) => {
217
+ // Do not run these tests in node
218
+ if ( typeof window === 'undefined' ) {
219
+ return ;
220
+ }
221
+
222
+ it ( 'returns false if the key is not set' , async ( ) => {
223
+ redirectPersistence . hasPendingRedirect = false ;
224
+ expect ( await _getAndClearPendingRedirectStatus ( _getInstance ( resolver ) , auth ) ) . to . be . false ;
225
+ } ) ;
226
+
227
+ it ( 'returns true if the key is found' , async ( ) => {
228
+ redirectPersistence . hasPendingRedirect = true ;
229
+ expect ( await _getAndClearPendingRedirectStatus ( _getInstance ( resolver ) , auth ) ) . to . be . true ;
230
+ } ) ;
231
+
232
+ it ( 'returns false if sessionStorage is permission denied' , async ( ) => {
233
+ _getInstance < PopupRedirectResolverInternal > ( resolver ) . _redirectPersistence = ErroringUnavailablePersistence as unknown as Persistence ;
234
+ expect ( await _getAndClearPendingRedirectStatus ( _getInstance ( resolver ) , auth ) ) . to . be . false ;
235
+ } ) ;
236
+ } ) ;
213
237
} ) ;
0 commit comments