EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
test_moniker.js
Go to the documentation of this file.
1// Test script for Moniker API integration
2// Run with: node scripts/test_moniker.js
3
4require('dotenv').config({ path: require('path').resolve(__dirname, '../.env') });
5const moniker = require('../services/moniker');
6
7/**
8 *
9 */
10async function testMonikerAPI() {
11 console.log('๐Ÿงช Testing Moniker API Integration\n');
12 console.log('='.repeat(50));
13
14 try {
15 // Test 1: Check if example.com is available
16 console.log('\n๐Ÿ“‹ Test 1: Checking domain availability');
17 console.log('-'.repeat(50));
18
19 const domain = 'example.com';
20 console.log(`Checking: ${domain}`);
21
22 const result = await moniker.checkDomain(domain);
23 console.log('โœ… Result:', JSON.stringify(result, null, 2));
24
25 // Test 2: Check multiple domains
26 console.log('\n๐Ÿ“‹ Test 2: Checking multiple domains');
27 console.log('-'.repeat(50));
28
29 const domains = ['test123456789.com', 'anothertestdomain123.com'];
30 console.log(`Checking: ${domains.join(', ')}`);
31
32 const results = await moniker.checkDomains(domains);
33 console.log('โœ… Results:', JSON.stringify(results, null, 2));
34
35 console.log('\n' + '='.repeat(50));
36 console.log('โœ… All tests passed!');
37 console.log('๐ŸŽ‰ Moniker API integration is working correctly');
38
39 } catch (error) {
40 console.error('\nโŒ Test failed:', error.message);
41 if (error.response) {
42 console.error('Response data:', error.response.data);
43 }
44 process.exit(1);
45 }
46}
47
48testMonikerAPI()
49 .then(() => {
50 console.log('\nโœจ Test complete');
51 process.exit(0);
52 })
53 .catch(err => {
54 console.error('\n๐Ÿ’ฅ Unexpected error:', err);
55 process.exit(1);
56 });