Add test for /help command in private chats

This commit is contained in:
JC Brand 2018-01-15 18:41:04 +01:00
parent 35275c8add
commit e9bba77b36
2 changed files with 26 additions and 3 deletions

View File

@ -20,6 +20,29 @@
return describe("Chatboxes", function() { return describe("Chatboxes", function() {
describe("A Chatbox", function () { describe("A Chatbox", function () {
it("has a /help command to show the available commands",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
test_utils.createContacts(_converse, 'current');
test_utils.openControlBox();
test_utils.openContactsPanel(_converse);
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
test_utils.openChatBoxFor(_converse, contact_jid);
var view = _converse.chatboxviews.get(contact_jid);
test_utils.sendMessage(view, '/help');
const info_messages = Array.prototype.slice.call(view.el.querySelectorAll('.chat-info:not(.chat-date)'), 0);
expect(info_messages.length).toBe(3);
expect(info_messages.pop().textContent).toBe('/help: Show this menu');
expect(info_messages.pop().textContent).toBe('/me: Write in the third person');
expect(info_messages.pop().textContent).toBe('/clear: Remove messages');
done();
}));
it("supports the /me command", it("supports the /me command",
mock.initConverseWithPromises( mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},

View File

@ -738,9 +738,9 @@
} }
else if (match[1] === "help") { else if (match[1] === "help") {
const msgs = [ const msgs = [
`<strong>/help</strong>:${__('Show this menu')}`, `<strong>/clear</strong>: ${__('Remove messages')}`,
`<strong>/me</strong>: ${__('Write in the third person')}`, `<strong>/me</strong>: ${__('Write in the third person')}`,
`<strong>/clear</strong>:${__('Remove messages')}` `<strong>/help</strong>: ${__('Show this menu')}`
]; ];
this.showHelpMessages(msgs); this.showHelpMessages(msgs);
return; return;