forked from stellarkit-lab-devtools/stellarkit-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-test.js
More file actions
54 lines (45 loc) · 1.65 KB
/
Copy pathrun-test.js
File metadata and controls
54 lines (45 loc) · 1.65 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
50
51
52
53
54
#!/usr/bin/env node
const request = require('supertest');
const app = require('./src/index');
async function runTest() {
console.log('Testing /fee-estimate endpoint...\n');
try {
const res = await request(app).get('/fee-estimate?operations=2');
console.log('Status:', res.statusCode);
console.log('Response:', JSON.stringify(res.body, null, 2));
if (res.statusCode !== 200) {
console.error('❌ TEST FAILED: Unexpected status code');
process.exit(1);
}
const data = res.body.data;
// Check required fields
const checks = [
{ field: 'operationCount', check: data.hasOwnProperty('operationCount') },
{ field: 'perOperation', check: data.hasOwnProperty('perOperation') },
{ field: 'context', check: data.hasOwnProperty('context') && typeof data.context === 'string' },
{ field: 'networkCongestion', check: data.hasOwnProperty('networkCongestion') && ['low', 'medium', 'high'].includes(data.networkCongestion) },
{ field: 'recommendation', check: data.hasOwnProperty('recommendation') && typeof data.recommendation === 'string' },
];
console.log('\n✓ Field Checks:');
let allPassed = true;
checks.forEach(({field, check}) => {
if (check) {
console.log(` ✓ ${field}`);
} else {
console.log(` ✗ ${field}`);
allPassed = false;
}
});
if (allPassed) {
console.log('\n✅ ALL TESTS PASSED');
process.exit(0);
} else {
console.log('\n❌ SOME TESTS FAILED');
process.exit(1);
}
} catch (err) {
console.error('Error running test:', err);
process.exit(1);
}
}
runTest();