From aa37704331e529248b612a803f94feb92505329f Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sat, 16 Sep 2023 18:32:00 +0200 Subject: [PATCH] chore: created simple command class method unit test --- src/tests/help.test.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/tests/help.test.ts diff --git a/src/tests/help.test.ts b/src/tests/help.test.ts new file mode 100644 index 0000000..ed039fb --- /dev/null +++ b/src/tests/help.test.ts @@ -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(''); + }); + }); +});