openai-plugins
Version:
A TypeScript library that provides an OpenAI-compatible client for the Model Context Protocol (MCP).
49 lines (40 loc) • 1.58 kB
text/typescript
/**
* Tests for configuration-related functionality
*/
describe('Configuration Tests', () => {
// Import needed module parts
const { setMcpLogLevel } = require('../dist/openai-mcp');
// Mock process.env
const originalEnv = process.env;
beforeEach(() => {
// Reset process.env before each test
jest.resetModules();
process.env = { ...originalEnv };
});
afterAll(() => {
// Restore process.env after all tests
process.env = originalEnv;
});
test('Environment variables can be used for configuration', () => {
// Set environment variables
process.env.MCP_SERVER_URL = 'http://example.com/mcp';
process.env.OPENAI_API_KEY = 'test-api-key';
// Require module again to pick up new environment variables
const config = jest.requireActual('../dist/openai-mcp');
// Just check that the module loads with the environment variables set
expect(config).toBeDefined();
});
test('Log level can be configured and is exported', () => {
// Import the log level
const { MCP_LOG_LVL } = require('../dist/openai-mcp');
// Should be defined
expect(MCP_LOG_LVL).toBeDefined();
// Test setting it to each valid level
// We're just checking it doesn't throw errors, not checking the values
// as that's tested in the logging tests
expect(() => setMcpLogLevel('debug')).not.toThrow();
expect(() => setMcpLogLevel('info')).not.toThrow();
expect(() => setMcpLogLevel('warn')).not.toThrow();
expect(() => setMcpLogLevel('error')).not.toThrow();
});
});