Skip to main content
Glama
NU-AquaLab

The Aleph MCP

by NU-AquaLab
client.test.jsโ€ข4.24 kB
#!/usr/bin/env node /** * Unit tests for The Aleph API Client */ const NetCoresAPIClient = require('../../src/client'); class ClientTests { constructor() { this.passed = 0; this.failed = 0; } async runTests() { console.log('๐Ÿงช Running The Aleph API Client Unit Tests\n'); await this.testClientInitialization(); await this.testUrlNormalization(); await this.testRetryLogic(); await this.testErrorHandling(); console.log(`\n๐Ÿ“Š Unit Test Results:`); console.log(`โœ… Passed: ${this.passed}`); console.log(`โŒ Failed: ${this.failed}`); return this.failed === 0; } async testClientInitialization() { console.log('๐Ÿ“‹ Testing client initialization...'); try { // Test default initialization const client1 = new NetCoresAPIClient(); this.assert(client1.baseUrl === 'https://thealeph.ai', 'Default URL should be production server'); this.assert(client1.timeout === 30000, 'Default timeout should be 30 seconds'); // Test custom initialization const client2 = new NetCoresAPIClient('http://localhost:8889', { timeout: 5000 }); this.assert(client2.baseUrl === 'http://localhost:8889', 'Custom URL should be set'); this.assert(client2.timeout === 5000, 'Custom timeout should be set'); // Test URL normalization (trailing slash removal) const client3 = new NetCoresAPIClient('http://example.com/'); this.assert(client3.baseUrl === 'http://example.com', 'Trailing slash should be removed'); console.log('โœ… Client initialization tests passed'); } catch (error) { console.log(`โŒ Client initialization tests failed: ${error.message}`); this.failed++; } } async testUrlNormalization() { console.log('๐Ÿ“‹ Testing URL normalization...'); try { const testCases = [ { input: 'http://example.com/', expected: 'http://example.com' }, { input: 'https://api.test.com', expected: 'https://api.test.com' }, { input: 'http://localhost:8889/', expected: 'http://localhost:8889' } ]; for (const testCase of testCases) { const client = new NetCoresAPIClient(testCase.input); this.assert(client.baseUrl === testCase.expected, `URL ${testCase.input} should normalize to ${testCase.expected}`); } console.log('โœ… URL normalization tests passed'); } catch (error) { console.log(`โŒ URL normalization tests failed: ${error.message}`); this.failed++; } } async testRetryLogic() { console.log('๐Ÿ“‹ Testing retry configuration...'); try { const client = new NetCoresAPIClient('http://localhost:8889', { retryAttempts: 5, retryDelay: 500 }); this.assert(client.retryAttempts === 5, 'Retry attempts should be configurable'); this.assert(client.retryDelay === 500, 'Retry delay should be configurable'); console.log('โœ… Retry logic tests passed'); } catch (error) { console.log(`โŒ Retry logic tests failed: ${error.message}`); this.failed++; } } async testErrorHandling() { console.log('๐Ÿ“‹ Testing error handling...'); try { const client = new NetCoresAPIClient('http://nonexistent.invalid'); // Test connection failure handling const result = await client.testConnection(); this.assert(result.success === false, 'Failed connection should return success: false'); this.assert(typeof result.error === 'string', 'Error should be included in result'); console.log('โœ… Error handling tests passed'); } catch (error) { console.log(`โŒ Error handling tests failed: ${error.message}`); this.failed++; } } assert(condition, message) { if (condition) { this.passed++; } else { this.failed++; throw new Error(message); } } } // Run tests if called directly if (require.main === module) { const tests = new ClientTests(); tests.runTests().then(success => { process.exit(success ? 0 : 1); }).catch(error => { console.error('Test runner error:', error); process.exit(1); }); } module.exports = ClientTests;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/NU-AquaLab/thealeph-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server