Files
api-codegen/tests/unit/config.test.ts
S.Gromov fe5d3ae091 feat: сделать split-клиент режимом по умолчанию
- добавлен operationsTree для сборки полного клиента
- удален режим генерации both
- обновлена документация под npm SDK workflow
- поднята версия пакета до 4.0.0
2026-06-30 10:46:15 +03:00

60 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { describe, test, expect } from 'bun:test';
import { validateConfig, type GeneratorConfig } from '../../src/config.js';
describe('config', () => {
describe('validateConfig', () => {
test('должен пройти валидацию для корректной конфигурации', () => {
const config: Partial<GeneratorConfig> = {
inputPath: './openapi.json',
outputPath: './output',
fileName: 'Api',
};
expect(() => validateConfig(config)).not.toThrow();
expect(validateConfig(config)).toBe(true);
});
test('должен пройти валидацию без опционального fileName', () => {
const config: Partial<GeneratorConfig> = {
inputPath: './openapi.json',
outputPath: './output',
};
expect(() => validateConfig(config)).not.toThrow();
expect(validateConfig(config)).toBe(true);
});
test('должен выбросить ошибку без inputPath', () => {
const config: Partial<GeneratorConfig> = {
outputPath: './output',
};
expect(() => validateConfig(config)).toThrow('Не указан путь к OpenAPI спецификации');
});
test('должен выбросить ошибку без outputPath', () => {
const config: Partial<GeneratorConfig> = {
inputPath: './openapi.json',
};
expect(() => validateConfig(config)).toThrow('Не указана директория для генерации');
});
test('должен выбросить ошибку без обоих обязательных полей', () => {
const config: Partial<GeneratorConfig> = {};
expect(() => validateConfig(config)).toThrow('Ошибка конфигурации');
});
test('должен выбросить ошибку для удаленного both режима', () => {
const config = {
inputPath: './openapi.json',
outputPath: './output',
mode: 'both',
};
expect(() => validateConfig(config as Partial<GeneratorConfig>)).toThrow('Доступные значения: split, single');
});
});
});