about summary refs log tree commit diff stats
path: root/tests/unittests
diff options
context:
space:
mode:
authorJohn Hernandez <129467592+H3rnand3zzz@users.noreply.github.com>2023-04-13 15:23:45 +0200
committerJohn Hernandez <129467592+H3rnand3zzz@users.noreply.github.com>2023-04-13 16:41:21 +0200
commit5b8b9074a294e32cbec5f64f61d867dbf0ca1d51 (patch)
treefdcf6666c4c3aef3fe63043b6bcb52e3cd6caeb8 /tests/unittests
parent766dc76e337c96e71edc698a8ee292014293c44f (diff)
downloadprofani-tty-5b8b9074a294e32cbec5f64f61d867dbf0ca1d51.tar.gz
Add nickname support for /roster remove
Add support of name/nickname instead of only JID for `/roster remove` command.

Add tests for it as well.
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/test_cmd_roster.c22
-rw-r--r--tests/unittests/test_cmd_roster.h1
-rw-r--r--tests/unittests/unittests.c1
3 files changed, 24 insertions, 0 deletions
diff --git a/tests/unittests/test_cmd_roster.c b/tests/unittests/test_cmd_roster.c
index 3908ba58..d848235b 100644
--- a/tests/unittests/test_cmd_roster.c
+++ b/tests/unittests/test_cmd_roster.c
@@ -114,12 +114,34 @@ cmd_roster_remove_sends_roster_remove_request(void** state)
     char* jid = "bob@server.org";
     gchar* args[] = { "remove", jid, NULL };
 
+    roster_create();
+    roster_add("bob@server.org", "bob", NULL, "both", FALSE);
+
+    will_return(connection_get_status, JABBER_CONNECTED);
+
+    expect_string(roster_send_remove, barejid, jid);
+
+    gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
+    assert_true(result);
+    roster_destroy();
+}
+
+void
+cmd_roster_remove_nickname_sends_roster_remove_request(void** state)
+{
+    char* jid = "bob@server.org";
+    gchar* args[] = { "remove", "bob", NULL };
+
+    roster_create();
+    roster_add("bob@server.org", "bob", NULL, "both", FALSE);
+
     will_return(connection_get_status, JABBER_CONNECTED);
 
     expect_string(roster_send_remove, barejid, jid);
 
     gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
     assert_true(result);
+    roster_destroy();
 }
 
 void
diff --git a/tests/unittests/test_cmd_roster.h b/tests/unittests/test_cmd_roster.h
index 49bd8db3..bc57f267 100644
--- a/tests/unittests/test_cmd_roster.h
+++ b/tests/unittests/test_cmd_roster.h
@@ -7,6 +7,7 @@ void cmd_roster_add_shows_message_when_no_jid(void** state);
 void cmd_roster_add_sends_roster_add_request(void** state);
 void cmd_roster_remove_shows_message_when_no_jid(void** state);
 void cmd_roster_remove_sends_roster_remove_request(void** state);
+void cmd_roster_remove_nickname_sends_roster_remove_request(void** state);
 void cmd_roster_nick_shows_message_when_no_jid(void** state);
 void cmd_roster_nick_shows_message_when_no_nick(void** state);
 void cmd_roster_nick_shows_message_when_no_contact_exists(void** state);
diff --git a/tests/unittests/unittests.c b/tests/unittests/unittests.c
index 2724aaa2..30f18c5c 100644
--- a/tests/unittests/unittests.c
+++ b/tests/unittests/unittests.c
@@ -584,6 +584,7 @@ main(int argc, char* argv[])
         unit_test(cmd_roster_add_sends_roster_add_request),
         unit_test(cmd_roster_remove_shows_message_when_no_jid),
         unit_test(cmd_roster_remove_sends_roster_remove_request),
+        unit_test(cmd_roster_remove_nickname_sends_roster_remove_request),
         unit_test(cmd_roster_nick_shows_message_when_no_jid),
         unit_test(cmd_roster_nick_shows_message_when_no_nick),
         unit_test(cmd_roster_nick_shows_message_when_no_contact_exists),