forked from PluralFlux/PluralFlux
one more test in commands.js, and removed console.error
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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]
|
||||||
|
})
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -189,6 +194,17 @@ describe('commands', () => {
|
|||||||
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(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user