Files
fast-next-template/frontend/tests/lib/api/client.test.ts
Felipe Cardoso b8d3248a48 Refactor password reset flow and improve ESLint integration
- Extracted password reset logic into `PasswordResetConfirmContent` wrapped in `Suspense` for cleaner and more modular component structure.
- Updated ESLint config to ignore generated files and added rules for stricter code quality (`eslint-comments`, `@typescript-eslint` adjustments).
- Automated insertion of `eslint-disable` in auto-generated TypeScript files through `generate-api-client.sh`.
- Replaced unsafe `any` type casts with safer `Record<string, unknown>` type assertions for TypeScript compliance.
- Added `lint:tests` script for pre-commit test coverage checks.
- Improved `useAuth` hooks and related type guards for better runtime safety and maintainability.
2025-11-01 06:04:35 +01:00

48 lines
1.7 KiB
TypeScript

/**
* Tests for API client configuration
*
* Tests ensure the client module loads and is configured correctly.
* Note: Interceptor behavior testing requires actual HTTP calls, which is
* better suited for integration/E2E tests. These unit tests verify setup.
*/
import { apiClient } from '@/lib/api/client';
import config from '@/config/app.config';
describe('API Client Configuration', () => {
it('should export apiClient instance', () => {
expect(apiClient).toBeDefined();
expect(apiClient.instance).toBeDefined();
});
it('should have correct baseURL', () => {
// Generated client already has /api/v1 in baseURL
expect(apiClient.instance.defaults.baseURL).toContain(config.api.url);
expect(apiClient.instance.defaults.baseURL).toContain('/api/v1');
});
it('should have correct timeout', () => {
expect(apiClient.instance.defaults.timeout).toBe(config.api.timeout);
});
it('should have correct default headers', () => {
expect(apiClient.instance.defaults.headers['Content-Type']).toBe('application/json');
});
it('should have request interceptors registered', () => {
// Interceptors are registered but not exposed in type definitions
// We verify by checking the interceptors object exists
expect(apiClient.instance.interceptors.request).toBeDefined();
});
it('should have response interceptors registered', () => {
// Interceptors are registered but not exposed in type definitions
// We verify by checking the interceptors object exists
expect(apiClient.instance.interceptors.response).toBeDefined();
});
it('should have setConfig method', () => {
expect(typeof apiClient.setConfig).toBe('function');
});
});