@@ -31,7 +31,7 @@ beforeEach(() => {
3131 baseApiUrl : 'https://api.ordercloud.io' ,
3232 apiVersion : 'v1' ,
3333 timeoutInMilliseconds : 10 * 1000 ,
34- clientID : null ,
34+ clientID : undefined ,
3535 } )
3636} )
3737
@@ -72,7 +72,7 @@ describe('has expired access token', () => {
7272 access_token : testdata . accessTokenFromRefresh ,
7373 expires_in : 32000000000 ,
7474 token_type : 'bearer' ,
75- refresh_token : undefined ,
75+ refresh_token : 'mockAccessToken' ,
7676 }
7777 return Promise . resolve ( response )
7878 } )
@@ -110,7 +110,7 @@ describe('has expired access token', () => {
110110 access_token : testdata . accessTokenFromRefresh ,
111111 expires_in : 32000000000 ,
112112 token_type : 'bearer' ,
113- refresh_token : undefined ,
113+ refresh_token : 'mockAccessToken' ,
114114 }
115115 return Promise . resolve ( response )
116116 } )
@@ -165,14 +165,15 @@ describe('has no access token', () => {
165165 Configuration . Set ( { clientID : testdata . clientID } )
166166
167167 const GetRefreshTokenSpy = jest . spyOn ( Tokens , 'GetRefreshToken' )
168+ const SetAccessTokenSpy = jest . spyOn ( Tokens , 'SetAccessToken' )
168169 const RefreshTokenSpy = jest
169170 . spyOn ( Auth , 'RefreshToken' )
170171 . mockImplementationOnce ( ( ) => {
171172 const response : RequiredDeep < AccessToken > = {
172173 access_token : testdata . accessTokenFromRefresh ,
173174 expires_in : 32000000000 ,
174175 token_type : 'bearer' ,
175- refresh_token : undefined ,
176+ refresh_token : 'mockAccessToken' ,
176177 }
177178 return Promise . resolve ( response )
178179 } )
@@ -186,6 +187,10 @@ describe('has no access token', () => {
186187 testdata . refreshToken ,
187188 testdata . clientID
188189 )
190+ expect ( SetAccessTokenSpy ) . toHaveBeenCalledTimes ( 1 )
191+ expect ( SetAccessTokenSpy ) . toHaveBeenCalledWith (
192+ testdata . accessTokenFromRefresh
193+ )
189194 expect ( mockAxios . delete ) . toHaveBeenCalledWith (
190195 `${ apiUrl } /products/${ testdata . productID } ` ,
191196 {
0 commit comments