seraph-agent
Version:
An extremely lightweight, SRE autonomous AI agent for seamless integration with common observability tasks.
33 lines (32 loc) • 1.3 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const anthropic_1 = require("../anthropic");
const sdk_1 = __importDefault(require("@anthropic-ai/sdk"));
jest.mock('@anthropic-ai/sdk');
describe('AnthropicProvider', () => {
const mockedAnthropic = sdk_1.default;
it('should handle errors from the Anthropic API', async () => {
const create = jest.fn().mockRejectedValue(new Error('Anthropic API error'));
mockedAnthropic.prototype.messages = { create };
const config = {
port: 8080,
workers: 4,
apiKey: 'test-key',
serverApiKey: null,
};
const provider = new anthropic_1.AnthropicProvider(config);
await expect(provider.generate('test prompt')).rejects.toThrow('Anthropic API error');
});
it('should throw an error if no API key is provided', () => {
const config = {
port: 8080,
workers: 4,
apiKey: null,
serverApiKey: null,
};
expect(() => new anthropic_1.AnthropicProvider(config)).toThrow('Anthropic API key not found in config.');
});
});