From 4d75a1101624bf346791c6ba560b4c603d436c89 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Mon, 22 May 2023 18:23:43 +0100 Subject: [PATCH] Add lengthInput.value IS NULL test --- tests/commands/timeout.test.ts | 35 +++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tests/commands/timeout.test.ts b/tests/commands/timeout.test.ts index b6f47c6..8d62207 100644 --- a/tests/commands/timeout.test.ts +++ b/tests/commands/timeout.test.ts @@ -313,7 +313,40 @@ describe('execute', () => { expect(interaction.reply).toBeCalledWith('Fields are required.'); }); - test.todo('GIVEN lengthInput.value IS NULL, EXPECT validation error'); + test('GIVEN lengthInput.value IS NULL, EXPECT validation error', async () => { + const command = new Timeout(); + + const interaction = { + reply: jest.fn(), + guild: mock(), + guildId: 'guildId', + options: { + get: jest.fn((value: string): CommandInteractionOption | null => { + switch (value) { + case 'target': + return { + user: {} as User, + member: {} as GuildMember + } as CommandInteractionOption; + case 'length': + return { + value: undefined, + } as CommandInteractionOption; + case 'reason': + return { + value: 'Test reason', + } as CommandInteractionOption; + default: + return null; + } + }), + } + } as unknown as CommandInteraction; + + await command.execute(interaction); + + expect(interaction.reply).toBeCalledWith('Fields are required.'); + }); test.todo('GIVEN targetMember IS NOT manageable by the bot, EXPECT insufficient permissions error');