59 lines
1.5 KiB
JavaScript
59 lines
1.5 KiB
JavaScript
// Simple test script for the player resolver
|
|
// Run with: node test-player-resolver.js
|
|
|
|
const { minecraftApi } = require('./src/lib/minecraft-api.ts');
|
|
|
|
async function testJavaPlayer() {
|
|
console.log('Testing Java player resolution...');
|
|
try {
|
|
const result = await minecraftApi.resolvePlayerIdentifier({
|
|
type: 'java',
|
|
username: 'Notch' // Famous Minecraft player
|
|
});
|
|
console.log('Java player result:', result);
|
|
} catch (error) {
|
|
console.error('Java player error:', error.message);
|
|
}
|
|
}
|
|
|
|
async function testBedrockPlayer() {
|
|
console.log('Testing Bedrock player resolution...');
|
|
try {
|
|
const result = await minecraftApi.resolvePlayerIdentifier({
|
|
type: 'bedrock',
|
|
username: 'TestGamertag' // This will likely fail but tests the API
|
|
});
|
|
console.log('Bedrock player result:', result);
|
|
} catch (error) {
|
|
console.error('Bedrock player error:', error.message);
|
|
}
|
|
}
|
|
|
|
async function testInvalidInput() {
|
|
console.log('Testing invalid input...');
|
|
try {
|
|
await minecraftApi.resolvePlayerIdentifier({
|
|
type: 'invalid',
|
|
username: ''
|
|
});
|
|
} catch (error) {
|
|
console.error('Expected error for invalid input:', error.message);
|
|
}
|
|
}
|
|
|
|
async function runTests() {
|
|
console.log('Starting player resolver tests...\n');
|
|
|
|
await testJavaPlayer();
|
|
console.log('\n');
|
|
|
|
await testBedrockPlayer();
|
|
console.log('\n');
|
|
|
|
await testInvalidInput();
|
|
console.log('\n');
|
|
|
|
console.log('Tests completed!');
|
|
}
|
|
|
|
runTests().catch(console.error);
|