chore: created simple command class method unit test

This commit is contained in:
Marius Begby committed 2023-09-16 18:32:00 +02:00
1 parent b73dee52ad
commit aa37704331
1 file changed
+36
+36
View File
@@ -0,0 +1,36 @@
import helpCommand from '../interactions/commands/info/help';
import { SlashCommandNumberOption } from 'discord.js';
import { BaseSlashCommandInteraction } from '../classes/interactions';
describe('HelpCommand', () => {
describe('getCommandParams', () => {
it('should return the correct command params', () => {
const command = {
data: {
options: [
new SlashCommandNumberOption()
.setName('optionname')
.setDescription('optionDescription')
.setRequired(true)
]
}
} as unknown as BaseSlashCommandInteraction;
const commandParams = helpCommand['getCommandParams'](command);
expect(commandParams).toBe('**`optionname`** ');
});
it('should return an empty string when no options are present', () => {
const command = {
data: {
options: []
}
} as unknown as BaseSlashCommandInteraction;
const commandParams = helpCommand['getCommandParams'](command);
expect(commandParams).toBe('');
});
});
});