mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Added /roster add test
This commit is contained in:
parent
93397e4581
commit
a578419d55
@ -68,3 +68,36 @@ void cmd_roster_shows_roster_when_no_args(void **state)
|
||||
free(help);
|
||||
roster_free();
|
||||
}
|
||||
|
||||
void cmd_roster_add_shows_message_when_no_jid(void)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { "add", NULL };
|
||||
|
||||
mock_connection_status(JABBER_CONNECTED);
|
||||
expect_cons_show("Usage: some usage");
|
||||
|
||||
gboolean result = cmd_roster(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_roster_add_sends_roster_add_request(void)
|
||||
{
|
||||
char *jid = "bob@server.org";
|
||||
char *nick = "bob";
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "add", jid, nick, NULL };
|
||||
|
||||
mock_roster_send_add_new();
|
||||
mock_connection_status(JABBER_CONNECTED);
|
||||
roster_send_add_new_expect(jid, nick);
|
||||
|
||||
gboolean result = cmd_roster(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
@ -3,3 +3,5 @@ void cmd_roster_shows_message_when_connecting(void **state);
|
||||
void cmd_roster_shows_message_when_disconnected(void **state);
|
||||
void cmd_roster_shows_message_when_undefined(void **state);
|
||||
void cmd_roster_shows_roster_when_no_args(void **state);
|
||||
void cmd_roster_add_shows_message_when_no_jid(void **state);
|
||||
void cmd_roster_add_sends_roster_add_request(void **state);
|
||||
|
@ -507,6 +507,8 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(cmd_roster_shows_message_when_disconnected),
|
||||
unit_test(cmd_roster_shows_message_when_undefined),
|
||||
unit_test(cmd_roster_shows_roster_when_no_args),
|
||||
unit_test(cmd_roster_add_shows_message_when_no_jid),
|
||||
unit_test(cmd_roster_add_sends_roster_add_request),
|
||||
};
|
||||
|
||||
return run_tests(all_tests);
|
||||
|
@ -96,6 +96,13 @@ _mock_presence_join_room(char *room, char*nick, char *passwd)
|
||||
check_expected(passwd);
|
||||
}
|
||||
|
||||
static void
|
||||
_mock_roster_send_add_new(const char *const barejid, const char * const name)
|
||||
{
|
||||
check_expected(barejid);
|
||||
check_expected(name);
|
||||
}
|
||||
|
||||
void
|
||||
mock_jabber_connect_with_details(void)
|
||||
{
|
||||
@ -139,6 +146,12 @@ mock_presence_join_room(void)
|
||||
presence_join_room = _mock_presence_join_room;
|
||||
}
|
||||
|
||||
void
|
||||
mock_roster_send_add_new(void)
|
||||
{
|
||||
roster_send_add_new = _mock_roster_send_add_new;
|
||||
}
|
||||
|
||||
void
|
||||
bookmark_get_list_returns(GList *bookmarks)
|
||||
{
|
||||
@ -260,3 +273,10 @@ presence_join_room_expect(char *room, char *nick, char *passwd)
|
||||
expect_string(_mock_presence_join_room, passwd, passwd);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
roster_send_add_new_expect(char *jid, char *nick)
|
||||
{
|
||||
expect_string(_mock_roster_send_add_new, barejid, jid);
|
||||
expect_string(_mock_roster_send_add_new, name, nick);
|
||||
}
|
||||
|
@ -36,4 +36,7 @@ void message_send_expect(char *message, char *recipient);
|
||||
void mock_presence_join_room(void);
|
||||
void presence_join_room_expect(char *room, char *nick, char *passwd);
|
||||
|
||||
void mock_roster_send_add_new(void);
|
||||
void roster_send_add_new_expect(char *jid, char *nick);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user