forked from PluralFlux/PluralFlux
testing bot login, added invoke for login
This commit is contained in:
@@ -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);
|
||||
}
|
||||
})
|
||||
})();
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user