"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const openai_1 = require("../../src/providers/openai");
const xai_1 = require("../../src/providers/xai");
jest.mock('../../src/providers/openai');
describe('xAI Provider', () => {
    beforeEach(() => {
        jest.clearAllMocks();
    });
    it('throws an error if no model name is provided', () => {
        expect(() => (0, xai_1.createXAIProvider)('xai:')).toThrow('Model name is required');
    });
    it('creates an xAI provider with specified model', () => {
        const provider = (0, xai_1.createXAIProvider)('xai:grok-2');
        expect(provider).toBeInstanceOf(openai_1.OpenAiChatCompletionProvider);
        expect(openai_1.OpenAiChatCompletionProvider).toHaveBeenCalledWith('grok-2', expect.any(Object));
    });
    it('sets the correct API base URL and API key environment variable', () => {
        (0, xai_1.createXAIProvider)('xai:grok-2');
        expect(openai_1.OpenAiChatCompletionProvider).toHaveBeenCalledWith(expect.any(String), expect.objectContaining({
            config: expect.objectContaining({
                apiBaseUrl: 'https://api.x.ai/v1',
                apiKeyEnvar: 'XAI_API_KEY',
            }),
        }));
    });
    it('merges provided options with xAI-specific config', () => {
        const options = {
            config: {
                temperature: 0.7,
                max_tokens: 100,
            },
            id: 'custom-id',
        };
        (0, xai_1.createXAIProvider)('xai:grok-2', options);
        expect(openai_1.OpenAiChatCompletionProvider).toHaveBeenCalledWith('grok-2', expect.objectContaining({
            config: expect.objectContaining({
                apiBaseUrl: 'https://api.x.ai/v1',
                apiKeyEnvar: 'XAI_API_KEY',
                temperature: 0.7,
                max_tokens: 100,
            }),
            id: 'custom-id',
        }));
    });
});
//# sourceMappingURL=xai.test.js.map