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:
@@ -13,12 +13,13 @@ jest.mock('discord.js', () => ({
|
||||
};
|
||||
callback(option);
|
||||
return {
|
||||
addStringOption: jest.fn().mockImplementation(callback => {
|
||||
const option = {
|
||||
addStringOption: jest.fn().mockImplementation(cb => {
|
||||
const strOption = {
|
||||
setName: jest.fn().mockReturnThis(),
|
||||
setDescription: jest.fn().mockReturnThis(),
|
||||
setRequired: jest.fn().mockReturnThis(),
|
||||
};
|
||||
callback(option);
|
||||
cb(strOption);
|
||||
return {
|
||||
setDefaultMemberPermissions: jest.fn().mockReturnThis(),
|
||||
toJSON: jest.fn().mockReturnValue({
|
||||
@@ -46,11 +47,12 @@ jest.mock('discord.js', () => ({
|
||||
toJSON: jest.fn(),
|
||||
}),
|
||||
PermissionFlagsBits: {
|
||||
KickMembers: 0x2n,
|
||||
KickMembers: 0x0000000000000002n,
|
||||
},
|
||||
}));
|
||||
|
||||
const kickCommand = require('../../commands/kick');
|
||||
const KickCommand = require('../../commands/kick').default;
|
||||
const kickCommand = new KickCommand();
|
||||
|
||||
describe('Kick Command', () => {
|
||||
describe('Command Structure', () => {
|
||||
@@ -152,7 +154,7 @@ describe('Kick Command', () => {
|
||||
|
||||
expect(mockKick).not.toHaveBeenCalled();
|
||||
expect(interaction.reply).toHaveBeenCalledWith({
|
||||
content: 'That user is not in this server!',
|
||||
content: 'Command failed: That user is not in this server!',
|
||||
ephemeral: true,
|
||||
});
|
||||
});
|
||||
@@ -173,7 +175,7 @@ describe('Kick Command', () => {
|
||||
expect(mockKick).not.toHaveBeenCalled();
|
||||
expect(interaction.reply).toHaveBeenCalledWith({
|
||||
content:
|
||||
'I cannot kick this user! They may have higher permissions than me.',
|
||||
'Command failed: I cannot kick this user! They may have higher permissions than me.',
|
||||
ephemeral: true,
|
||||
});
|
||||
});
|
||||
@@ -195,7 +197,7 @@ describe('Kick Command', () => {
|
||||
await kickCommand.execute(interaction);
|
||||
|
||||
expect(interaction.reply).toHaveBeenCalledWith({
|
||||
content: 'There was an error trying to kick this user!',
|
||||
content: 'Command failed: Failed to kick user',
|
||||
ephemeral: true,
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user