import { describe, expect, it } from 'vitest' import * as httpIndex from './index' import * as client from './client' import * as authSession from './auth-session' import * as errors from '@/lib/errors' describe('lib/http/index', () => { describe('exports from client', () => { it('should export get function', () => { expect(httpIndex.get).toBeDefined() expect(typeof httpIndex.get).toBe('function') }) it('should export post function', () => { expect(httpIndex.post).toBeDefined() expect(typeof httpIndex.post).toBe('function') }) it('should export put function', () => { expect(httpIndex.put).toBeDefined() expect(typeof httpIndex.put).toBe('function') }) it('should export del function', () => { expect(httpIndex.del).toBeDefined() expect(typeof httpIndex.del).toBe('function') }) it('should export download function', () => { expect(httpIndex.download).toBeDefined() expect(typeof httpIndex.download).toBe('function') }) it('should export upload function', () => { expect(httpIndex.upload).toBeDefined() expect(typeof httpIndex.upload).toBe('function') }) it('should export request function', () => { expect(httpIndex.request).toBeDefined() expect(typeof httpIndex.request).toBe('function') }) }) describe('exports from auth-session', () => { it('should export getAccessToken function', () => { expect(httpIndex.getAccessToken).toBeDefined() expect(typeof httpIndex.getAccessToken).toBe('function') }) it('should export setAccessToken function', () => { expect(httpIndex.setAccessToken).toBeDefined() expect(typeof httpIndex.setAccessToken).toBe('function') }) it('should export clearAccessToken function', () => { expect(httpIndex.clearAccessToken).toBeDefined() expect(typeof httpIndex.clearAccessToken).toBe('function') }) it('should export isAccessTokenExpired function', () => { expect(httpIndex.isAccessTokenExpired).toBeDefined() expect(typeof httpIndex.isAccessTokenExpired).toBe('function') }) it('should export getCurrentUser function', () => { expect(httpIndex.getCurrentUser).toBeDefined() expect(typeof httpIndex.getCurrentUser).toBe('function') }) it('should export setCurrentUser function', () => { expect(httpIndex.setCurrentUser).toBeDefined() expect(typeof httpIndex.setCurrentUser).toBe('function') }) it('should export getCurrentRoles function', () => { expect(httpIndex.getCurrentRoles).toBeDefined() expect(typeof httpIndex.getCurrentRoles).toBe('function') }) it('should export setCurrentRoles function', () => { expect(httpIndex.setCurrentRoles).toBeDefined() expect(typeof httpIndex.setCurrentRoles).toBe('function') }) it('should export isAdmin function', () => { expect(httpIndex.isAdmin).toBeDefined() expect(typeof httpIndex.isAdmin).toBe('function') }) it('should export getRoleCodes function', () => { expect(httpIndex.getRoleCodes).toBeDefined() expect(typeof httpIndex.getRoleCodes).toBe('function') }) it('should export isAuthenticated function', () => { expect(httpIndex.isAuthenticated).toBeDefined() expect(typeof httpIndex.isAuthenticated).toBe('function') }) it('should export clearSession function', () => { expect(httpIndex.clearSession).toBeDefined() expect(typeof httpIndex.clearSession).toBe('function') }) it('should export isRefreshing function', () => { expect(httpIndex.isRefreshing).toBeDefined() expect(typeof httpIndex.isRefreshing).toBe('function') }) it('should export startRefreshing function', () => { expect(httpIndex.startRefreshing).toBeDefined() expect(typeof httpIndex.startRefreshing).toBe('function') }) it('should export endRefreshing function', () => { expect(httpIndex.endRefreshing).toBeDefined() expect(typeof httpIndex.endRefreshing).toBe('function') }) it('should export getRefreshPromise function', () => { expect(httpIndex.getRefreshPromise).toBeDefined() expect(typeof httpIndex.getRefreshPromise).toBe('function') }) it('should export setRefreshPromise function', () => { expect(httpIndex.setRefreshPromise).toBeDefined() expect(typeof httpIndex.setRefreshPromise).toBe('function') }) it('should export clearRefreshPromise function', () => { expect(httpIndex.clearRefreshPromise).toBeDefined() expect(typeof httpIndex.clearRefreshPromise).toBe('function') }) }) describe('exports from errors', () => { it('should export AppError class', () => { expect(httpIndex.AppError).toBeDefined() expect(typeof httpIndex.AppError).toBe('function') }) it('should export ErrorType constant', () => { expect(httpIndex.ErrorType).toBeDefined() expect(httpIndex.ErrorType.BUSINESS).toBe('BUSINESS') expect(httpIndex.ErrorType.NETWORK).toBe('NETWORK') expect(httpIndex.ErrorType.AUTH).toBe('AUTH') }) it('should export isAppError function', () => { expect(httpIndex.isAppError).toBeDefined() expect(typeof httpIndex.isAppError).toBe('function') }) }) describe('integration', () => { it('should be able to create AppError from exported class', () => { const error = new httpIndex.AppError(1001, 'Test error') expect(error).toBeInstanceOf(httpIndex.AppError) expect(error.code).toBe(1001) expect(error.message).toBe('Test error') }) it('should be able to check error type with isAppError', () => { const error = new httpIndex.AppError(1001, 'Test error') expect(httpIndex.isAppError(error)).toBe(true) }) it('should have consistent ErrorType values', () => { expect(httpIndex.ErrorType).toEqual(errors.ErrorType) }) }) })