forked from domdomegg/airtable-mcp-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice-test.js
More file actions
49 lines (42 loc) · 1.44 KB
/
Copy pathservice-test.js
File metadata and controls
49 lines (42 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import nodeFetch from 'node-fetch';
// Simple service class for testing
class SimpleService {
constructor(apiKey, baseUrl, fetch) {
console.log('Constructor called with:');
console.log('- apiKey:', apiKey);
console.log('- baseUrl:', baseUrl);
console.log('- fetch type:', typeof fetch);
this.apiKey = apiKey;
this.baseUrl = baseUrl;
this.fetch = fetch;
}
async testFetch() {
console.log('Testing fetch inside the class...');
console.log('this.fetch type:', typeof this.fetch);
try {
const response = await this.fetch('https://example.com');
console.log('Fetch successful! Status:', response.status);
const text = await response.text();
console.log('Response length:', text.length);
return true;
} catch (error) {
console.error('Error in fetch:', error);
return false;
}
}
}
// Test with different parameter combinations
async function runTests() {
console.log('========= Test 1: All parameters =========');
const service1 = new SimpleService('test-key', 'https://example.com', nodeFetch);
await service1.testFetch();
console.log('\n========= Test 2: Default fetch =========');
const service2 = new SimpleService('test-key', 'https://example.com');
// This should error since we didn't provide fetch in this example
try {
await service2.testFetch();
} catch (error) {
console.error('Expected error:', error.message);
}
}
runTests();