@@ -14,9 +14,8 @@ import {
1414} from 'bun:test'
1515
1616import { validateApiKey } from '../../hooks/use-auth-query'
17+ import * as AuthModule from '../../utils/auth'
1718import { getAuthTokenDetails , saveUserCredentials } from '../../utils/auth'
18-
19- import type * as AuthModule from '../../utils/auth'
2019import type { GetUserInfoFromApiKeyFn } from '@codebuff/common/types/contracts/database'
2120import type { Logger } from '@codebuff/common/types/contracts/logger'
2221
@@ -58,10 +57,8 @@ describe('Returning User Authentication helpers', () => {
5857 } )
5958
6059 test ( 'should load auth token from credentials file for returning user' , ( ) => {
61- const authModule = require ( '../../utils/auth' ) as typeof AuthModule
62-
63- spyOn ( authModule , 'getConfigDir' ) . mockReturnValue ( tempConfigDir )
64- spyOn ( authModule , 'getCredentialsPath' ) . mockReturnValue (
60+ spyOn ( AuthModule , 'getConfigDir' ) . mockReturnValue ( tempConfigDir )
61+ spyOn ( AuthModule , 'getCredentialsPath' ) . mockReturnValue (
6562 path . join ( tempConfigDir , 'credentials.json' ) ,
6663 )
6764
@@ -73,10 +70,8 @@ describe('Returning User Authentication helpers', () => {
7370 } )
7471
7572 test ( 'should fall back to CODEBUFF_API_KEY when credentials are missing' , ( ) => {
76- const authModule = require ( '../../utils/auth' ) as typeof AuthModule
77-
78- spyOn ( authModule , 'getConfigDir' ) . mockReturnValue ( tempConfigDir )
79- spyOn ( authModule , 'getCredentialsPath' ) . mockReturnValue (
73+ spyOn ( AuthModule , 'getConfigDir' ) . mockReturnValue ( tempConfigDir )
74+ spyOn ( AuthModule , 'getCredentialsPath' ) . mockReturnValue (
8075 path . join ( tempConfigDir , 'credentials.json' ) ,
8176 )
8277
@@ -88,10 +83,8 @@ describe('Returning User Authentication helpers', () => {
8883 } )
8984
9085 test ( 'should validate stored credentials without blocking the UI thread' , async ( ) => {
91- const authModule = require ( '../../utils/auth' ) as typeof AuthModule
92-
93- spyOn ( authModule , 'getConfigDir' ) . mockReturnValue ( tempConfigDir )
94- spyOn ( authModule , 'getCredentialsPath' ) . mockReturnValue (
86+ spyOn ( AuthModule , 'getConfigDir' ) . mockReturnValue ( tempConfigDir )
87+ spyOn ( AuthModule , 'getCredentialsPath' ) . mockReturnValue (
9588 path . join ( tempConfigDir , 'credentials.json' ) ,
9689 )
9790
0 commit comments