Files
opencommit/test/unit/errors.test.ts
di-sukharev cf27085ac9 fix(cli): tighten proxy and setup behavior
Support explicit proxy disabling and ambient proxy fallback without leaking env state into config.

Improve first-run detection, endpoint-specific error messaging, diff exclusions, and runtime helper boundaries covered by unit tests.
2026-04-10 15:16:11 +03:00

30 lines
896 B
TypeScript

import {
formatUserFriendlyError,
ServiceUnavailableError
} from '../../src/utils/errors';
describe('formatUserFriendlyError', () => {
it('should keep provider wording when no custom API URL is configured', () => {
const formatted = formatUserFriendlyError(
new ServiceUnavailableError('openai'),
'openai'
);
expect(formatted.message).toEqual(
'The openai service is temporarily unavailable.'
);
});
it('should use configured endpoint wording when a custom API URL is provided', () => {
const formatted = formatUserFriendlyError(
new ServiceUnavailableError('openai'),
'openai',
{ baseURL: 'http://127.0.0.1:1234/v1' }
);
expect(formatted.message).toContain('configured API endpoint');
expect(formatted.message).toContain('127.0.0.1:1234');
expect(formatted.message).not.toContain('openai service');
});
});