about summary refs log tree commit diff stats
path: root/tests/test_chat_session.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_chat_session.c')
-rw-r--r--tests/test_chat_session.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/test_chat_session.c b/tests/test_chat_session.c
index a93c64b6..bcb8dcce 100644
--- a/tests/test_chat_session.c
+++ b/tests/test_chat_session.c
@@ -122,4 +122,42 @@ void removes_chat_session_on_cancel_for_fulljid(void **state)
     gboolean exists = chat_session_exists(barejid);
 
     assert_false(exists);
+}
+
+void removes_chat_session_on_offline_matching_resource(void **state)
+{
+    char *barejid = "myjid@server.org";
+    char *resource = "work";
+
+    chat_session_on_message_send(barejid);
+    chat_session_on_incoming_message(barejid, resource, TRUE);
+    chat_session_on_offline(barejid, resource);
+    gboolean exists = chat_session_exists(barejid);
+
+    assert_false(exists);
+}
+
+void does_not_remove_chat_session_on_offline_different_resource(void **state)
+{
+    char *barejid = "myjid@server.org";
+    char *resource = "work";
+    char *offline_resource = "home";
+
+    chat_session_on_message_send(barejid);
+    chat_session_on_incoming_message(barejid, resource, TRUE);
+    chat_session_on_offline(barejid, offline_resource);
+    gboolean exists = chat_session_exists(barejid);
+
+    assert_true(exists);
+}
+
+void does_not_remove_chat_session_on_offline_null_resource(void **state)
+{
+    char *barejid = "myjid@server.org";
+
+    chat_session_on_message_send(barejid);
+    chat_session_on_offline(barejid, NULL);
+    gboolean exists = chat_session_exists(barejid);
+
+    assert_true(exists);
 }
\ No newline at end of file