-
Notifications
You must be signed in to change notification settings - Fork 170
Expand file tree
/
Copy pathtest_search.js
More file actions
50 lines (41 loc) · 1.37 KB
/
Copy pathtest_search.js
File metadata and controls
50 lines (41 loc) · 1.37 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
// Test the new search commands
const googleCommand = require('./commands/google');
const apkCommand = require('./commands/apk');
const playstoreCommand = require('./commands/playstore');
// Mock sock object
const mockSock = {
sendMessage: async (chatId, message) => {
console.log(`📤 Message to ${chatId}:`, message.text.substring(0, 100) + '...');
return { messageId: 'test' };
}
};
// Mock message object
function createMockMessage(text) {
return {
key: {
remoteJid: '1234567890@s.whatsapp.net'
},
pushName: 'TestUser'
};
}
// Test function
async function testCommand(command, args, commandName) {
console.log(`\n🧪 Testing ${commandName}: "${args.join(' ')}"`);
const message = createMockMessage();
try {
await command.execute(mockSock, message, args);
console.log('✅ Command executed successfully');
} catch (error) {
console.error('❌ Command failed:', error.message);
}
}
// Run tests
async function runTests() {
console.log('🚀 Starting Search Commands Tests\n');
// Test help messages (empty args)
await testCommand(googleCommand, [], 'Google Search');
await testCommand(apkCommand, [], 'APK Search');
await testCommand(playstoreCommand, [], 'Play Store Search');
console.log('\n🏁 Tests completed');
}
runTests().catch(console.error);