@@ -288,39 +288,36 @@ describe('Auth Flows', () => {
288288 } )
289289
290290 it ( 'should tokenProvider work even after changing fetchTokenInfo funtion' , async ( ) => {
291- const onTokenInfoRefreshedMock = jest . fn ( )
292-
293- const tokenProvider = new TokenProvider (
294- {
295- sdkAuth : authClient ,
296- onTokenInfoRefreshed : onTokenInfoRefreshedMock ,
297- }
298- )
299- tokenProvider . fetchTokenInfo = ( sdkAuth ) =>
300- sdkAuth . refreshTokenFlow ( encodeURIComponent ( "invalid refresh token" ) ) ;
301-
302- try {
303- await tokenProvider . getAccessToken ( )
304- } catch ( err ) {
305- expect ( err . toString ( ) ) . toEqual (
306- expect . stringContaining (
307- 'BadRequest: The refresh token was not found. It may have expired.'
308- )
309- )
310- tokenProvider . fetchTokenInfo = ( sdkAuth ) =>
311- sdkAuth . anonymousFlow ( ) ;
312- const tokenInfo = await tokenProvider . getTokenInfo ( ) ;
313-
314- // check returned properties
315- expect ( tokenInfo ) . toHaveProperty ( 'access_token' )
316- expect ( tokenInfo . scope ) . toMatch (
317- `manage_project:${ projectKey } anonymous_id`
291+ const onTokenInfoRefreshedMock = jest . fn ( )
292+
293+ const tokenProvider = new TokenProvider ( {
294+ sdkAuth : authClient ,
295+ onTokenInfoRefreshed : onTokenInfoRefreshedMock ,
296+ } )
297+ tokenProvider . fetchTokenInfo = ( sdkAuth ) =>
298+ sdkAuth . refreshTokenFlow ( encodeURIComponent ( 'invalid refresh token' ) )
299+
300+ try {
301+ await tokenProvider . getAccessToken ( )
302+ } catch ( err ) {
303+ expect ( err . toString ( ) ) . toEqual (
304+ expect . stringContaining (
305+ 'BadRequest: The refresh token was not found. It may have expired.'
318306 )
319- expect ( tokenInfo ) . toHaveProperty ( 'expires_in' )
320- expect ( tokenInfo ) . toHaveProperty ( 'expires_at' )
321- expect ( tokenInfo ) . toHaveProperty ( 'refresh_token' )
322- expect ( tokenInfo ) . toHaveProperty ( 'token_type' , 'Bearer' )
323- }
307+ )
308+ tokenProvider . fetchTokenInfo = ( sdkAuth ) => sdkAuth . anonymousFlow ( )
309+ const tokenInfo = await tokenProvider . getTokenInfo ( )
310+
311+ // check returned properties
312+ expect ( tokenInfo ) . toHaveProperty ( 'access_token' )
313+ expect ( tokenInfo . scope ) . toMatch (
314+ `manage_project:${ projectKey } anonymous_id`
315+ )
316+ expect ( tokenInfo ) . toHaveProperty ( 'expires_in' )
317+ expect ( tokenInfo ) . toHaveProperty ( 'expires_at' )
318+ expect ( tokenInfo ) . toHaveProperty ( 'refresh_token' )
319+ expect ( tokenInfo ) . toHaveProperty ( 'token_type' , 'Bearer' )
320+ }
324321 } )
325322 } )
326323
0 commit comments