forked from PluralFlux/PluralFlux
added dash to commands.js and test to pass
This commit is contained in:
@@ -45,8 +45,12 @@ cmds.memberCommand = async function(message, args) {
|
|||||||
await message.reply({embeds: [reply]})
|
await message.reply({embeds: [reply]})
|
||||||
}
|
}
|
||||||
else if (typeof reply === 'object') {
|
else if (typeof reply === 'object') {
|
||||||
const errorsText = reply.errors.length > 0 ? reply.errors.join('\n- ') : null;
|
// The little dash is so that the errors print out in bullet points in Fluxer
|
||||||
return await message.reply({content: `${reply.success} ${errorsText ? `\n\n${enums.err.ERRORS_OCCURRED}\n` + errorsText : ""}`, embeds: [reply.embed]})
|
const errorsText = reply.errors.length > 0 ? '- ' + reply.errors.join('\n- ') : null;
|
||||||
|
return await message.reply({
|
||||||
|
content: `${reply.success} ${errorsText ? `\n\n${enums.err.ERRORS_OCCURRED}\n` + errorsText : ""}`,
|
||||||
|
embeds: [reply.embed]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,17 +107,19 @@ describe('commands', () => {
|
|||||||
const reply = {
|
const reply = {
|
||||||
errors: ['error', 'error2'],
|
errors: ['error', 'error2'],
|
||||||
success: 'success',
|
success: 'success',
|
||||||
embed: {}
|
embed: {title: 'hi'}
|
||||||
}
|
}
|
||||||
|
const expected = {
|
||||||
|
content: `success \n\n${enums.err.ERRORS_OCCURRED}\n- error\n- error2`,
|
||||||
|
embeds: [reply.embed]
|
||||||
|
}
|
||||||
|
console.log(expected)
|
||||||
memberHelper.parseMemberCommand = jest.fn().mockResolvedValue(reply);
|
memberHelper.parseMemberCommand = jest.fn().mockResolvedValue(reply);
|
||||||
// Act
|
// Act
|
||||||
await commands.memberCommand(message, args);
|
await commands.memberCommand(message, args);
|
||||||
// Assert
|
// Assert
|
||||||
expect(message.reply).toHaveBeenCalledTimes(1);
|
expect(message.reply).toHaveBeenCalledTimes(1);
|
||||||
expect(message.reply).toHaveBeenCalledWith({
|
expect(message.reply).toHaveBeenCalledWith(expected)
|
||||||
content: `success\n\n${enums.err.ERRORS_OCCURRED}\n\nerror\nerror2`,
|
|
||||||
embeds: [reply.embed]
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('importCommand', () => {
|
describe('importCommand', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user