refactor: update command tests to use require syntax and improve error handling
Deploy to NAS / deploy (push) Successful in 1m4s
Deploy to NAS / deploy (push) Successful in 1m4s
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
import { jest } from '@jest/globals';
|
||||
const { createMockInteraction } = require('../utils/testUtils');
|
||||
|
||||
// Mock axios
|
||||
jest.unstable_mockModule('axios', () => ({
|
||||
jest.mock('axios', () => ({
|
||||
__esModule: true,
|
||||
default: {
|
||||
post: jest.fn(),
|
||||
},
|
||||
}));
|
||||
const axios = require('axios').default;
|
||||
|
||||
// Mock the discord.js module
|
||||
jest.unstable_mockModule('discord.js', () => ({
|
||||
// Mock discord.js
|
||||
jest.mock('discord.js', () => ({
|
||||
SlashCommandBuilder: jest.fn().mockReturnValue({
|
||||
setName: jest.fn().mockReturnThis(),
|
||||
setDescription: jest.fn().mockReturnThis(),
|
||||
@@ -38,9 +40,7 @@ jest.unstable_mockModule('discord.js', () => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
const axios = (await import('axios')).default;
|
||||
const { createMockInteraction } = await import('../utils/testUtils.js');
|
||||
const AskCommand = (await import('../../commands/ask.js')).default;
|
||||
const AskCommand = require('../../commands/ask').default;
|
||||
const askCommand = new AskCommand();
|
||||
|
||||
describe('Ask Command', () => {
|
||||
@@ -258,4 +258,4 @@ describe('Ask Command', () => {
|
||||
await expect(askCommand.run(interaction)).rejects.toThrow('Failed to follow up');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user