forked from PluralFlux/PluralFlux
put console.error in commands
This commit is contained in:
@@ -111,6 +111,7 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,6 @@ jest.mock('../src/helpers/importHelper.js', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
jest.mock('console', () => {
|
|
||||||
return {error: jest.fn()}
|
|
||||||
})
|
|
||||||
|
|
||||||
import {messageHelper} from "../src/helpers/messageHelper.js";
|
import {messageHelper} from "../src/helpers/messageHelper.js";
|
||||||
|
|
||||||
@@ -197,15 +194,18 @@ describe('commands', () => {
|
|||||||
expect(message.reply).toHaveBeenCalledWith(expected);
|
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
|
// Arrange
|
||||||
importHelper.pluralKitImport = jest.fn().mockImplementation(() => {
|
importHelper.pluralKitImport = jest.fn().mockImplementation(() => {
|
||||||
throw new Error('error');
|
throw new Error('error');
|
||||||
});
|
});
|
||||||
|
jest.spyOn(global.console, 'error').mockImplementation(() => {})
|
||||||
// Act
|
// Act
|
||||||
await commands.importCommand(message, args);
|
await commands.importCommand(message, args);
|
||||||
expect(message.reply).toHaveBeenCalledTimes(1);
|
expect(message.reply).toHaveBeenCalledTimes(1);
|
||||||
expect(message.reply).toHaveBeenCalledWith('error');
|
expect(message.reply).toHaveBeenCalledWith('error');
|
||||||
|
expect(console.error).toHaveBeenCalledTimes(1);
|
||||||
|
expect(console.error).toHaveBeenCalledWith(new Error('error'));
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user