about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-03-08 21:37:06 +0000
committerJames Booth <boothj5@gmail.com>2014-03-08 21:37:06 +0000
commitbafc0f25068fb8a13a4357b67867716d8d907ce9 (patch)
tree5f474fe85e4e07fc94d19a71bbbcea7e0c0adf14
parentb177250f47f5599943b6772aed43de49834147e2 (diff)
downloadprofani-tty-bafc0f25068fb8a13a4357b67867716d8d907ce9.tar.gz
Added test for using account->muc_nick
-rw-r--r--tests/test_cmd_join.c27
-rw-r--r--tests/test_cmd_join.h1
-rw-r--r--tests/testsuite.c1
3 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_cmd_join.c b/tests/test_cmd_join.c
index f7810401..9dad6823 100644
--- a/tests/test_cmd_join.c
+++ b/tests/test_cmd_join.c
@@ -114,3 +114,30 @@ void cmd_join_uses_supplied_nick(void **state)
 
     free(help);
 }
+
+void cmd_join_uses_account_nick_when_not_supplied(void **state)
+{
+    char *account_name = "an_account";
+    char *room = "room@conf.server.org";
+    char *account_nick = "a_nick";
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { room, NULL };
+    ProfAccount *account = account_new(account_name, "user@server.org", NULL,
+        TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, 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(room, account_nick, NULL);
+    ui_room_join_expect(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 fa2084fb..d40a79fc 100644
--- a/tests/test_cmd_join.h
+++ b/tests/test_cmd_join.h
@@ -5,3 +5,4 @@ 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);
 void cmd_join_uses_supplied_nick(void **state);
+void cmd_join_uses_account_nick_when_not_supplied(void **state);
diff --git a/tests/testsuite.c b/tests/testsuite.c
index 841181bc..8e0697e6 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -494,6 +494,7 @@ int main(int argc, char* argv[]) {
         unit_test(cmd_join_shows_usage_when_no_args),
         unit_test(cmd_join_shows_error_message_when_invalid_room_jid),
         unit_test(cmd_join_uses_supplied_nick),
+        unit_test(cmd_join_uses_account_nick_when_not_supplied),
     };
 
     return run_tests(all_tests);