11import api from '../api' ;
22
3+ jest . mock ( '@/lib/auth-client' , ( ) => ( {
4+ authClient : {
5+ getSession : jest . fn ( ) . mockResolvedValue ( { data : null } ) ,
6+ } ,
7+ } ) ) ;
8+
39/**
410 * API Client 단위 테스트
5- * 쿠키 기반 인증으로 전환 후 Bearer Token 추출 로직이 제거되었는지 확인합니다 .
11+ * 프로덕션 크로스 오리진 환경에서 Bearer 토큰으로 인증합니다 .
612 */
713describe ( 'API Client' , ( ) => {
814 describe ( 'Axios 설정' , ( ) => {
@@ -20,20 +26,9 @@ describe('API Client', () => {
2026 } ) ;
2127
2228 describe ( '요청 인터셉터' , ( ) => {
23- it ( 'should not have request interceptors that set Authorization header' , ( ) => {
24- // Bearer Token 추출 로직이 제거되었으므로
25- // 요청 인터셉터가 없거나 Authorization 헤더를 설정하지 않아야 함
29+ it ( 'should have request interceptor for Bearer token' , ( ) => {
2630 const requestInterceptors = api . interceptors . request . handlers ;
27-
28- // 요청 인터셉터가 없거나, Authorization 헤더를 설정하지 않는지 확인
29- if ( requestInterceptors . length > 0 ) {
30- // 인터셉터가 있다면 Authorization 헤더를 설정하지 않는지 확인
31- // 실제로는 인터셉터가 없어야 함 (Bearer Token 로직 제거됨)
32- expect ( requestInterceptors . length ) . toBe ( 0 ) ;
33- } else {
34- // 인터셉터가 없는 것이 정상 (Bearer Token 로직 제거됨)
35- expect ( requestInterceptors . length ) . toBe ( 0 ) ;
36- }
31+ expect ( requestInterceptors . length ) . toBeGreaterThan ( 0 ) ;
3732 } ) ;
3833 } ) ;
3934
0 commit comments