@@ -214,37 +214,43 @@ export default (QUnit: QUnit) => {
214214 } ) ;
215215
216216 test ( 'successfully retrieves user access tokens from backend API for a specific provider' , async assert => {
217- const fakeResponse = [
218- {
219- external_account_id : 'eac_2dYS7stz9bgxQsSRvNqEAHhuxvW' ,
220- object : 'oauth_access_token' ,
221- token : '<token>' ,
222- provider : 'oauth_google' ,
223- public_metadata : { } ,
224- label : null ,
225- scopes : [ 'email' , 'profile' ] ,
226- } ,
227- ] ;
217+ const fakeResponse = {
218+ data : [
219+ {
220+ external_account_id : 'eac_2dYS7stz9bgxQsSRvNqEAHhuxvW' ,
221+ object : 'oauth_access_token' ,
222+ token : '<token>' ,
223+ provider : 'oauth_google' ,
224+ public_metadata : { } ,
225+ label : null ,
226+ scopes : [ 'email' , 'profile' ] ,
227+ } ,
228+ ] ,
229+ total_count : 1 ,
230+ } ;
228231
229232 fakeFetch = sinon . stub ( runtime , 'fetch' ) ;
230233 fakeFetch . onCall ( 0 ) . returns ( jsonOk ( fakeResponse ) ) ;
231234
232235 const response = await apiClient . users . getUserOauthAccessToken ( 'user_deadbeef' , 'oauth_google' ) ;
233236
234- assert . equal ( response [ 0 ] . externalAccountId , 'eac_2dYS7stz9bgxQsSRvNqEAHhuxvW' ) ;
235- assert . equal ( response [ 0 ] . provider , 'oauth_google' ) ;
236- assert . equal ( response [ 0 ] . token , '<token>' ) ;
237- assert . deepEqual ( response [ 0 ] . scopes , [ 'email' , 'profile' ] ) ;
237+ assert . equal ( response . data [ 0 ] . externalAccountId , 'eac_2dYS7stz9bgxQsSRvNqEAHhuxvW' ) ;
238+ assert . equal ( response . data [ 0 ] . provider , 'oauth_google' ) ;
239+ assert . equal ( response . data [ 0 ] . token , '<token>' ) ;
240+ assert . deepEqual ( response . data [ 0 ] . scopes , [ 'email' , 'profile' ] ) ;
238241
239242 assert . ok (
240- fakeFetch . calledOnceWith ( 'https://api.clerk.test/v1/users/user_deadbeef/oauth_access_tokens/oauth_google' , {
241- method : 'GET' ,
242- headers : {
243- Authorization : 'Bearer deadbeef' ,
244- 'Content-Type' : 'application/json' ,
245- 'User-Agent' : '@clerk/backend@0.0.0-test' ,
243+ fakeFetch . calledOnceWith (
244+ 'https://api.clerk.test/v1/users/user_deadbeef/oauth_access_tokens/oauth_google?paginated=true' ,
245+ {
246+ method : 'GET' ,
247+ headers : {
248+ Authorization : 'Bearer deadbeef' ,
249+ 'Content-Type' : 'application/json' ,
250+ 'User-Agent' : '@clerk/backend@0.0.0-test' ,
251+ } ,
246252 } ,
247- } ) ,
253+ ) ,
248254 ) ;
249255 } ) ;
250256 } ) ;
0 commit comments