@@ -94,7 +94,7 @@ describe('GoTrueAdminApi', () => {
94
94
} )
95
95
} )
96
96
97
- describe ( 'User fetch ' , ( ) => {
97
+ describe ( 'List users ' , ( ) => {
98
98
test ( 'listUsers() should return registered users' , async ( ) => {
99
99
const { email } = mockUserCredentials ( )
100
100
const { error : createError , data : createdUser } = await createNewUserWithEmail ( { email } )
@@ -114,6 +114,18 @@ describe('GoTrueAdminApi', () => {
114
114
expect ( emails ) . toContain ( email )
115
115
} )
116
116
117
+ test ( 'listUsers() returns AuthError when page is invalid' , async ( ) => {
118
+ const { error, data } = await serviceRoleApiClient . listUsers ( {
119
+ page : - 1 ,
120
+ perPage : 10 ,
121
+ } )
122
+
123
+ expect ( error ) . not . toBeNull ( )
124
+ expect ( data . users ) . toEqual ( [ ] )
125
+ } )
126
+ } )
127
+
128
+ describe ( 'Get user' , ( ) => {
117
129
test ( 'getUser() fetches a user by their access_token' , async ( ) => {
118
130
const { email, password } = mockUserCredentials ( )
119
131
const { error : initialError , data } = await authClientWithSession . signUp ( {
@@ -435,6 +447,27 @@ describe('GoTrueAdminApi', () => {
435
447
436
448
expect ( error ?. message ) . toMatch ( / ^ i n v a l i d J W T / )
437
449
} )
450
+
451
+ test ( 'signOut() fails with invalid scope' , async ( ) => {
452
+ const { email, password } = mockUserCredentials ( )
453
+
454
+ const { error : signUpError } = await authClientWithSession . signUp ( {
455
+ email,
456
+ password,
457
+ } )
458
+ expect ( signUpError ) . toBeNull ( )
459
+
460
+ const { data : { session } , error } = await authClientWithSession . signInWithPassword ( {
461
+ email,
462
+ password,
463
+ } )
464
+ expect ( error ) . toBeNull ( )
465
+ expect ( session ) . not . toBeNull ( )
466
+
467
+ await expect ( authClientWithSession . signOut ( { scope : 'invalid_scope' as any } ) ) . rejects . toThrow (
468
+ '@supabase/auth-js: Parameter scope must be one of global, local, others'
469
+ )
470
+ } )
438
471
} )
439
472
} )
440
473
@@ -475,18 +508,6 @@ describe('GoTrueAdminApi', () => {
475
508
} )
476
509
} )
477
510
478
- describe ( 'List Users' , ( ) => {
479
- test ( 'listUsers() returns AuthError when page is invalid' , async ( ) => {
480
- const { error, data } = await serviceRoleApiClient . listUsers ( {
481
- page : - 1 ,
482
- perPage : 10 ,
483
- } )
484
-
485
- expect ( error ) . not . toBeNull ( )
486
- expect ( data . users ) . toEqual ( [ ] )
487
- } )
488
- } )
489
-
490
511
describe ( 'Update User' , ( ) => {
491
512
test ( 'updateUserById() returns AuthError when user id is invalid' , async ( ) => {
492
513
const { error, data } = await serviceRoleApiClient . updateUserById ( NON_EXISTANT_USER_ID , {
0 commit comments