about summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-12-27 17:25:30 +0000
committerJames Booth <boothj5@gmail.com>2013-12-27 17:25:30 +0000
commit976f3e303a550b9594899bafd4498b531ea7c86e (patch)
treea7538cdc3ec0bd676c80004e6738947f4fd0d262 /tests
parentc3fbaf8b2a75fc28df933e5f48fda2e8468b7e80 (diff)
downloadprofani-tty-976f3e303a550b9594899bafd4498b531ea7c86e.tar.gz
Added /sub command test
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cmd_sub.c31
-rw-r--r--tests/test_cmd_sub.h1
-rw-r--r--tests/testsuite.c4
3 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_cmd_sub.c b/tests/test_cmd_sub.c
new file mode 100644
index 00000000..4f459be3
--- /dev/null
+++ b/tests/test_cmd_sub.c
@@ -0,0 +1,31 @@
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#include "xmpp/xmpp.h"
+#include "xmpp/mock_xmpp.h"
+
+#include "ui/ui.h"
+#include "ui/mock_ui.h"
+
+#include "command/commands.h"
+
+void cmd_sub_shows_message_when_not_connected(void **state)
+{
+    mock_cons_show();
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { NULL };
+
+    mock_connection_status(JABBER_DISCONNECTED);
+
+    expect_cons_show("You are currently not connected.");
+
+    gboolean result = cmd_sub(args, *help);
+    assert_true(result);
+
+    free(help);
+}
diff --git a/tests/test_cmd_sub.h b/tests/test_cmd_sub.h
new file mode 100644
index 00000000..b8c95c1a
--- /dev/null
+++ b/tests/test_cmd_sub.h
@@ -0,0 +1 @@
+void cmd_sub_shows_message_when_not_connected(void **state);
diff --git a/tests/testsuite.c b/tests/testsuite.c
index e906c358..1ffd2a71 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -8,6 +8,7 @@
 #include "test_cmd_connect.h"
 #include "test_cmd_account.h"
 #include "test_cmd_rooms.h"
+#include "test_cmd_sub.h"
 #include "test_history.h"
 #include "test_jid.h"
 #include "test_parser.h"
@@ -252,6 +253,9 @@ int main(int argc, char* argv[]) {
         unit_test(cmd_account_clear_checks_account_exists),
         unit_test(cmd_account_clear_shows_message_when_account_doesnt_exist),
         unit_test(cmd_account_clear_shows_message_when_invalid_property),
+
+        unit_test(cmd_sub_shows_message_when_not_connected),
+
     };
     return run_tests(tests);
 }