-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-api.js
More file actions
73 lines (60 loc) · 2.87 KB
/
test-api.js
File metadata and controls
73 lines (60 loc) · 2.87 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import fetch from 'node-fetch';
async function testMatchingAPI() {
try {
console.log('===== TESTING MATCH 1-2 =====');
// Test Match Score
const scoreResponse = await fetch('http://localhost:5000/api/matching/score/1/2');
const scoreData = await scoreResponse.json();
console.log('Match Score:', scoreData);
// Test Match Analysis with Premium
const analysisResponse = await fetch('http://localhost:5000/api/matching/analysis/1/2', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ premium: true })
});
if (!analysisResponse.ok) {
console.error('Analysis API error:', analysisResponse.status, await analysisResponse.text());
return;
}
const analysisData = await analysisResponse.json();
console.log('Match Analysis:', JSON.stringify(analysisData, null, 2));
console.log('\n===== TESTING MATCH 3-4 =====');
// Test another match
const scoreResponse2 = await fetch('http://localhost:5000/api/matching/score/3/4');
const scoreData2 = await scoreResponse2.json();
console.log('Match Score:', scoreData2);
// Test Match Analysis with Premium for second pair
const analysisResponse2 = await fetch('http://localhost:5000/api/matching/analysis/3/4', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ premium: true })
});
if (!analysisResponse2.ok) {
console.error('Analysis API error:', analysisResponse2.status, await analysisResponse2.text());
return;
}
const analysisData2 = await analysisResponse2.json();
console.log('Match Analysis:', JSON.stringify(analysisData2, null, 2));
console.log('\n===== TESTING RECOMMENDATIONS =====');
// Test recommendations
const standardRecResponse = await fetch('http://localhost:5000/api/matching/recommendations/1');
const standardRecData = await standardRecResponse.json();
console.log('Standard Recommendations:', JSON.stringify(standardRecData, null, 2).slice(0, 500) + '...');
// Test premium recommendations
const premiumRecResponse = await fetch('http://localhost:5000/api/matching/recommendations/1?premium=true');
const premiumRecData = await premiumRecResponse.json();
console.log('Premium Recommendations:', JSON.stringify(premiumRecData, null, 2).slice(0, 500) + '...');
console.log('\n===== TESTING POTENTIAL MATCHES =====');
// Test potential matches
const potentialMatchesResponse = await fetch('http://localhost:5000/api/matching/potential-matches/1');
const potentialMatchesData = await potentialMatchesResponse.json();
console.log('Potential Matches:', JSON.stringify(potentialMatchesData, null, 2).slice(0, 500) + '...');
} catch (error) {
console.error('Error testing API:', error);
}
}
testMatchingAPI();