feat: переработать кастомизацию HttpClient
- добавлен плоский ApiConfig с lifecycle hooks - добавлены ApiError, retry context, timeout и кастомные parser/serializer - обновлены примеры, документация и тесты под новый API
This commit is contained in:
@@ -148,7 +148,7 @@ describe('Generated Client', () => {
|
||||
expect(content).toContain('https://api.example.com');
|
||||
}, 30000);
|
||||
|
||||
test('метод setSecurityData должен работать', async () => {
|
||||
test('HttpClient должен поддерживать lifecycle hooks', async () => {
|
||||
const outputPath = join(tempDir, 'output');
|
||||
const config: GeneratorConfig = {
|
||||
inputPath: FIXTURES.WITH_AUTH,
|
||||
@@ -162,8 +162,12 @@ describe('Generated Client', () => {
|
||||
const generatedFile = join(outputPath, 'http-client.ts');
|
||||
const content = await readTextFile(generatedFile);
|
||||
|
||||
// Проверяем наличие метода для установки токена
|
||||
expect(content).toContain('setSecurityData');
|
||||
// Проверяем наличие hooks для кастомизации запросов
|
||||
expect(content).toContain('onRequest?: RequestInterceptor');
|
||||
expect(content).toContain('onResponse?: ResponseInterceptor');
|
||||
expect(content).toContain('onError?: ErrorInterceptor');
|
||||
expect(content).not.toContain('baseApiParams');
|
||||
expect(content).not.toContain('setSecurityData');
|
||||
}, 30000);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user