about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/commands.c3
-rw-r--r--tests/test_cmd_join.c17
-rw-r--r--tests/test_cmd_join.h1
-rw-r--r--tests/testsuite.c1
4 files changed, 21 insertions, 1 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index 6eae7d09..9bfae727 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1591,7 +1591,8 @@ cmd_join(gchar **args, struct cmd_help_t help)
 
     Jid *room_arg = jid_create(args[0]);
     if (room_arg == NULL) {
-        cons_show_error("Specified room has incorrect format");
+        cons_show_error("Specified room has incorrect format.");
+        cons_show("");
         return TRUE;
     }
 
diff --git a/tests/test_cmd_join.c b/tests/test_cmd_join.c
index 88ca8c17..225aaf5b 100644
--- a/tests/test_cmd_join.c
+++ b/tests/test_cmd_join.c
@@ -67,6 +67,23 @@ void cmd_join_shows_usage_when_no_args(void **state)
     free(help);
 }
 
+void cmd_join_shows_error_message_when_invalid_room_jid(void **state)
+{
+    mock_cons_show_error();
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "//@@/", NULL };
+
+    mock_connection_status(JABBER_CONNECTED);
+
+    expect_cons_show_error("Specified room has incorrect format.");
+    expect_cons_show("");
+
+    gboolean result = cmd_join(args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
 /*
 void cmd_connect_shows_usage_when_no_server_value(void **state)
 {
diff --git a/tests/test_cmd_join.h b/tests/test_cmd_join.h
index c8e3c408..f6abdd8c 100644
--- a/tests/test_cmd_join.h
+++ b/tests/test_cmd_join.h
@@ -3,3 +3,4 @@ void cmd_join_shows_message_when_connecting(void **state);
 void cmd_join_shows_message_when_disconnected(void **state);
 void cmd_join_shows_message_when_undefined(void **state);
 void cmd_join_shows_usage_when_no_args(void **state);
+void cmd_join_shows_error_message_when_invalid_room_jid(void **state);
diff --git a/tests/testsuite.c b/tests/testsuite.c
index 73a9362a..0ba32305 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -492,6 +492,7 @@ int main(int argc, char* argv[]) {
         unit_test(cmd_join_shows_message_when_disconnected),
         unit_test(cmd_join_shows_message_when_undefined),
         unit_test(cmd_join_shows_usage_when_no_args),
+        unit_test(cmd_join_shows_error_message_when_invalid_room_jid),
     };
 
     return run_tests(all_tests);