about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--tests/test_cmd_join.c30
-rw-r--r--tests/test_cmd_join.h1
-rw-r--r--tests/testsuite.c1
3 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_cmd_join.c b/tests/test_cmd_join.c
index 871e3295..19e4de9a 100644
--- a/tests/test_cmd_join.c
+++ b/tests/test_cmd_join.c
@@ -170,3 +170,33 @@ void cmd_join_uses_account_nick_when_not_supplied(void **state)
 
     free(help);
 }
+
+void cmd_join_uses_password_when_supplied(void **state)
+{
+    char *account_name = "an_account";
+    char *room = "room";
+    char *password = "a_password";
+    char *account_nick = "a_nick";
+    char *account_service = "a_service";
+    char *expected_room = "room@a_service";
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { room, "passwd", password, NULL };
+    ProfAccount *account = account_new(account_name, "user@server.org", NULL,
+        TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick);
+
+    muc_init();
+
+    mock_connection_status(JABBER_CONNECTED);
+    mock_connection_account_name(account_name);
+    mock_accounts_get_account();
+    accounts_get_account_expect_and_return(account_name, account);
+
+    mock_presence_join_room();
+    presence_join_room_expect(expected_room, account_nick, password);
+    ui_room_join_expect(expected_room);
+
+    gboolean result = cmd_join(args, *help);
+    assert_true(result);
+
+    free(help);
+}
diff --git a/tests/test_cmd_join.h b/tests/test_cmd_join.h
index c4e9234f..812aee87 100644
--- a/tests/test_cmd_join.h
+++ b/tests/test_cmd_join.h
@@ -7,3 +7,4 @@ void cmd_join_shows_error_message_when_invalid_room_jid(void **state);
 void cmd_join_uses_account_mucservice_when_no_service_specified(void **state);
 void cmd_join_uses_supplied_nick(void **state);
 void cmd_join_uses_account_nick_when_not_supplied(void **state);
+void cmd_join_uses_password_when_supplied(void **state);
diff --git a/tests/testsuite.c b/tests/testsuite.c
index ee929435..0c2101f3 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -496,6 +496,7 @@ int main(int argc, char* argv[]) {
         unit_test(cmd_join_uses_account_mucservice_when_no_service_specified),
         unit_test(cmd_join_uses_supplied_nick),
         unit_test(cmd_join_uses_account_nick_when_not_supplied),
+        unit_test(cmd_join_uses_password_when_supplied),
     };
 
     return run_tests(all_tests);