1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Added test for using account->muc_nick

This commit is contained in:
James Booth 2014-03-08 21:37:06 +00:00
parent b177250f47
commit bafc0f2506
3 changed files with 29 additions and 0 deletions

View File

@ -114,3 +114,30 @@ void cmd_join_uses_supplied_nick(void **state)
free(help); 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);
}

View File

@ -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_usage_when_no_args(void **state);
void cmd_join_shows_error_message_when_invalid_room_jid(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_supplied_nick(void **state);
void cmd_join_uses_account_nick_when_not_supplied(void **state);

View File

@ -494,6 +494,7 @@ int main(int argc, char* argv[]) {
unit_test(cmd_join_shows_usage_when_no_args), unit_test(cmd_join_shows_usage_when_no_args),
unit_test(cmd_join_shows_error_message_when_invalid_room_jid), unit_test(cmd_join_shows_error_message_when_invalid_room_jid),
unit_test(cmd_join_uses_supplied_nick), unit_test(cmd_join_uses_supplied_nick),
unit_test(cmd_join_uses_account_nick_when_not_supplied),
}; };
return run_tests(all_tests); return run_tests(all_tests);