put console.error in commands

This commit is contained in:
Aster Fialla
2026-02-24 16:58:39 -05:00
parent 8919fce34f
commit 8d946ce921
2 changed files with 5 additions and 4 deletions

View File

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

View File

@@ -24,9 +24,6 @@ jest.mock('../src/helpers/importHelper.js', () => {
}
}
})
jest.mock('console', () => {
return {error: jest.fn()}
})
import {messageHelper} from "../src/helpers/messageHelper.js";
@@ -197,15 +194,18 @@ describe('commands', () => {
expect(message.reply).toHaveBeenCalledWith(expected);
})
test('if pluralKitImport returns one error, reply with error', async () => {
test('if pluralKitImport returns one error, reply with error and log it', async () => {
// Arrange
importHelper.pluralKitImport = jest.fn().mockImplementation(() => {
throw new Error('error');
});
jest.spyOn(global.console, 'error').mockImplementation(() => {})
// Act
await commands.importCommand(message, args);
expect(message.reply).toHaveBeenCalledTimes(1);
expect(message.reply).toHaveBeenCalledWith('error');
expect(console.error).toHaveBeenCalledTimes(1);
expect(console.error).toHaveBeenCalledWith(new Error('error'));
})
})