Browse Source

Add test for `/help` command in private chats

JC Brand 7 years ago
parent
commit
e9bba77b36
2 changed files with 26 additions and 3 deletions
  1. 23 0
      spec/chatbox.js
  2. 3 3
      src/converse-chatview.js

+ 23 - 0
spec/chatbox.js

@@ -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'], {},

+ 3 - 3
src/converse-chatview.js

@@ -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>/me</strong>:${__('Write in the third person')}`,
-                                `<strong>/clear</strong>:${__('Remove messages')}`
+                                `<strong>/clear</strong>: ${__('Remove messages')}`,
+                                `<strong>/me</strong>: ${__('Write in the third person')}`,
+                                `<strong>/help</strong>: ${__('Show this menu')}`
                                 ];
                                 ];
                             this.showHelpMessages(msgs);
                             this.showHelpMessages(msgs);
                             return;
                             return;