refactor: update ask command and test utilities to use ES modules; improve error handling and response formatting

This commit is contained in:
2025-12-24 11:21:30 -05:00
parent 94494c1ca5
commit 2ac855b765
6 changed files with 192 additions and 356 deletions
+4 -7
View File
@@ -1,11 +1,13 @@
// Test utilities for Discord.js bot testing
import { jest } from '@jest/globals';
/**
* Creates a mock interaction object with common properties and methods
* @param {Object} options - Customization options for the mock interaction
* @returns {Object} Mock interaction object
*/
const createMockInteraction = (options = {}) => ({
export const createMockInteraction = (options = {}) => ({
commandName: options.commandName || 'test-command',
user: {
id: options.userId || 'mock-user-id',
@@ -74,7 +76,7 @@ const createMockInteraction = (options = {}) => ({
* @param {Object} options - Customization options for the mock client
* @returns {Object} Mock client object
*/
const createMockClient = (options = {}) => ({
export const createMockClient = (options = {}) => ({
user: {
id: options.clientId || 'mock-client-id',
username: options.clientUsername || 'MockBot',
@@ -89,8 +91,3 @@ const createMockClient = (options = {}) => ({
login: jest.fn().mockResolvedValue('token'),
destroy: jest.fn().mockResolvedValue(),
});
module.exports = {
createMockInteraction,
createMockClient,
};