From bfb5bf9cbb6b1e9cfd09a23d05268fa61106165c Mon Sep 17 00:00:00 2001 From: Aster Fialla Date: Mon, 23 Feb 2026 10:47:02 -0500 Subject: [PATCH] testing bot login, added invoke for login --- src/bot.js | 4 ++-- tests/bot.test.js | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/bot.js b/src/bot.js index f9054d7..23712e6 100644 --- a/src/bot.js +++ b/src/bot.js @@ -80,7 +80,7 @@ function printGuilds() { } const debouncePrintGuilds = utils.debounce(printGuilds, 2000); -const debounceLogin = utils.debounce(client.login, 60000); +export const debounceLogin = utils.debounce(client.login, 60000); (async () => { try { @@ -90,4 +90,4 @@ const debounceLogin = utils.debounce(client.login, 60000); console.error('Login failed:', err); process.exit(1); } -}) \ No newline at end of file +})(); \ No newline at end of file diff --git a/tests/bot.test.js b/tests/bot.test.js index a824fb5..7fe82e8 100644 --- a/tests/bot.test.js +++ b/tests/bot.test.js @@ -58,7 +58,7 @@ const {commands} = require("../src/commands.js"); const {webhookHelper} = require("../src/helpers/webhookHelper.js"); const {utils} = require("../src/helpers/utils.js"); -const {handleMessageCreate, client} = require("../src/bot.js"); +let {handleMessageCreate, client, debounceLogin} = require("../src/bot.js"); env.config(); @@ -251,6 +251,13 @@ describe('bot', () => { }) }) + test('calls debounceLogin with correct argument', () => { + // Act + debounceLogin = jest.fn().mockResolvedValue(); + // Assert + expect(debounceLogin).toHaveBeenCalledTimes(1); + expect(debounceLogin).toHaveBeenCalledWith(process.env.FLUXER_BOT_TOKEN) + }) afterEach(() => { // restore the spy created with spyOn