one more test in commands.js, and removed console.error

This commit is contained in:
Aster Fialla
2026-02-24 16:22:38 -05:00
parent 2bf218683a
commit 5d8ff9c6c6
2 changed files with 21 additions and 6 deletions

View File

@@ -112,7 +112,6 @@ cmds.importCommand = async function(message, args) {
} }
// If just one error was returned. // If just one error was returned.
else { else {
console.error(error);
return await message.reply(error.message); return await message.reply(error.message);
} }
} }

View File

@@ -49,7 +49,7 @@ describe('commands', () => {
jest.resetModules(); jest.resetModules();
jest.clearAllMocks(); jest.clearAllMocks();
message= { message = {
author: { author: {
username: username, username: username,
id: authorId, id: authorId,
@@ -84,7 +84,9 @@ describe('commands', () => {
test('if parseMemberCommand returns error, log error and reply with error', () => { test('if parseMemberCommand returns error, log error and reply with error', () => {
// Arrange // Arrange
memberHelper.parseMemberCommand = jest.fn().mockImplementation(() => {throw new Error('error')}); memberHelper.parseMemberCommand = jest.fn().mockImplementation(() => {
throw new Error('error')
});
// Act // Act
return commands.memberCommand(message, args).catch(() => { return commands.memberCommand(message, args).catch(() => {
expect(message.reply).toHaveBeenCalledTimes(1); expect(message.reply).toHaveBeenCalledTimes(1);
@@ -115,7 +117,10 @@ describe('commands', () => {
return commands.memberCommand(message, args).catch(() => { return commands.memberCommand(message, args).catch(() => {
// Assert // Assert
expect(message.reply).toHaveBeenCalledTimes(1); expect(message.reply).toHaveBeenCalledTimes(1);
expect(message.reply).toHaveBeenCalledWith({content: `success\n\n${enums.err.ERRORS_OCCURRED}\n\nerror\nerror2}`, embeds: [reply.embed]}) expect(message.reply).toHaveBeenCalledWith({
content: `success\n\n${enums.err.ERRORS_OCCURRED}\n\nerror\nerror2}`,
embeds: [reply.embed]
})
}); });
}) })
}) })
@@ -157,7 +162,7 @@ describe('commands', () => {
expect(importHelper.pluralKitImport).toHaveBeenCalledWith(authorId, attachmentUrl); expect(importHelper.pluralKitImport).toHaveBeenCalledWith(authorId, attachmentUrl);
}) })
test('if pluralKitImport returns aggregate errors with length <= 2000, send errors.', async() => { test('if pluralKitImport returns aggregate errors with length <= 2000, send errors.', async () => {
// Arrange // Arrange
const args = [""]; const args = [""];
message.content = 'pf;import' message.content = 'pf;import'
@@ -188,7 +193,18 @@ describe('commands', () => {
// Assert // Assert
expect(message.reply).toHaveBeenCalledTimes(1); expect(message.reply).toHaveBeenCalledTimes(1);
expect(message.reply).toHaveBeenCalledWith(expected); expect(message.reply).toHaveBeenCalledWith(expected);
}) })
test('if pluralKitImport returns one error, reply with error', async() => {
// Arrange
importHelper.pluralKitImport = jest.fn().mockImplementation(() => {
throw new Error('error');
});
// Act
await commands.importCommand(message, args);
expect(message.reply).toHaveBeenCalledTimes(1);
expect(message.reply).toHaveBeenCalledWith('error');
})
}) })
afterEach(() => { afterEach(() => {