@@ -52,7 +52,7 @@ function createMockSession(overrides?: {
5252function createMockAuth ( session : ReturnType < typeof createMockSession > | null = createMockSession ( ) ) {
5353 return {
5454 api : {
55- getSession : vi . fn ( async ( ) => session ) ,
55+ getSession : vi . fn ( ( ) => Promise . resolve ( session ) ) ,
5656 } ,
5757 }
5858}
@@ -83,7 +83,7 @@ describe('identifyUser', () => {
8383 identifyUser ( log , session )
8484
8585 expect ( log . set ) . toHaveBeenCalledOnce ( )
86- const call = log . setCalls [ 0 ]
86+ const [ call ] = log . setCalls
8787
8888 expect ( call . userId ) . toBe ( 'usr_123' )
8989
@@ -201,7 +201,7 @@ describe('identifyUser', () => {
201201 } ) ,
202202 } )
203203
204- const call = log . setCalls [ 0 ]
204+ const [ call ] = log . setCalls
205205 expect ( call . organization ) . toBe ( 'org_42' )
206206 expect ( call . role ) . toBe ( 'admin' )
207207 expect ( call . userId ) . toBe ( 'usr_123' )
@@ -274,7 +274,7 @@ describe('createAuthMiddleware', () => {
274274 const log = createMockLogger ( )
275275 const auth = {
276276 api : {
277- getSession : vi . fn ( async ( ) => { throw new Error ( 'DB connection failed' ) } ) ,
277+ getSession : vi . fn ( ( ) => Promise . reject ( new Error ( 'DB connection failed' ) ) ) ,
278278 } ,
279279 }
280280 const identify = createAuthMiddleware ( auth )
@@ -444,7 +444,7 @@ describe('createAuthIdentifier', () => {
444444 const log = createMockLogger ( )
445445 const auth = {
446446 api : {
447- getSession : vi . fn ( async ( ) => { throw new Error ( 'DB error' ) } ) ,
447+ getSession : vi . fn ( ( ) => Promise . reject ( new Error ( 'DB error' ) ) ) ,
448448 } ,
449449 }
450450 const hook = createAuthIdentifier ( auth )
0 commit comments