@@ -13,7 +13,7 @@ describe('api/client – request interceptor', () => {
1313 it ( 'attaches Bearer token when localStorage has one' , async ( ) => {
1414 localStorage . setItem ( 'token' , 'my-jwt' )
1515 // Re-import to run the module with the token already set
16- const { client } = await import ( './client' )
16+ await import ( './client' )
1717 // Inspect the interceptor by checking what an outgoing request config looks like
1818 // via axios adapter mock
1919 const mockAdapter = vi . fn ( ) . mockResolvedValue ( { data : { } , status : 200 , headers : { } , config : { } } )
@@ -24,7 +24,7 @@ describe('api/client – request interceptor', () => {
2424 testClient . interceptors . request . use ( ( config ) => {
2525 const token = localStorage . getItem ( 'token' )
2626 if ( token ) config . headers . Authorization = `Bearer ${ token } `
27- capturedConfig = config as Record < string , unknown >
27+ capturedConfig = config as unknown as Record < string , unknown >
2828 return config
2929 } )
3030 testClient . defaults . adapter = mockAdapter
@@ -34,13 +34,13 @@ describe('api/client – request interceptor', () => {
3434
3535 it ( 'omits Authorization header when no token' , async ( ) => {
3636 // No token in localStorage
37- let capturedConfig : { headers : Record < string , unknown > } | null = null
37+ let capturedConfig : { headers : { Authorization ?: string } } | null = null
3838 const testClient = axios . create ( { baseURL : '/api/v1' } )
3939 const mockAdapter = vi . fn ( ) . mockResolvedValue ( { data : { } , status : 200 , headers : { } , config : { } } )
4040 testClient . interceptors . request . use ( ( config ) => {
4141 const token = localStorage . getItem ( 'token' )
4242 if ( token ) config . headers . Authorization = `Bearer ${ token } `
43- capturedConfig = config as { headers : Record < string , unknown > }
43+ capturedConfig = config as unknown as { headers : { Authorization ?: string } }
4444 return config
4545 } )
4646 testClient . defaults . adapter = mockAdapter
0 commit comments