@gotake/gotake-sdk
Version:
SDK for interacting with GoTake blockchain contracts
82 lines (65 loc) • 2.2 kB
JavaScript
const fs = require('fs');
const path = require('path');
async function testCommonJSImport() {
try {
console.log('Testing CommonJS import...');
const { GoTakeSDK } = require('../dist/cjs/index.js');
if (typeof GoTakeSDK === 'function') {
console.log('✅ CommonJS import successful');
// Test instantiation
const sdk = new GoTakeSDK();
console.log('✅ CommonJS instantiation successful');
} else {
console.log('❌ CommonJS import failed - GoTakeSDK is not a constructor');
}
} catch (error) {
console.log('❌ CommonJS import failed:', error.message);
}
}
async function testESModuleImport() {
try {
console.log('Testing ES Module import...');
// Dynamic import for ES modules
const { GoTakeSDK } = await import('../dist/esm/index.js');
if (typeof GoTakeSDK === 'function') {
console.log('✅ ES Module import successful');
// Test instantiation
const sdk = new GoTakeSDK();
console.log('✅ ES Module instantiation successful');
} else {
console.log('❌ ES Module import failed - GoTakeSDK is not a constructor');
}
} catch (error) {
console.log('❌ ES Module import failed:', error.message);
}
}
function checkFileStructure() {
console.log('Checking build output structure...');
const expectedFiles = [
'dist/cjs/index.js',
'dist/esm/index.js',
'dist/types/index.d.ts'
];
expectedFiles.forEach(file => {
const fullPath = path.join(__dirname, '..', file);
if (fs.existsSync(fullPath)) {
console.log(`✅ ${file} exists`);
} else {
console.log(`❌ ${file} missing`);
}
});
}
async function main() {
console.log('=== SDK Import Test ===\n');
checkFileStructure();
console.log('');
await testCommonJSImport();
console.log('');
await testESModuleImport();
console.log('');
console.log('=== Test Complete ===');
}
if (require.main === module) {
main().catch(console.error);
}
module.exports = { main };