summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp')
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp
new file mode 100644
index 0000000..985a34b
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <gtest/gtest.h>
+
+#include <Swiften/Elements/MIXUpdateSubscription.h>
+#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
+
+using namespace Swift;
+
+TEST(MIXUpdateSubscriptionParserTest, XEP0369_Example28) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<update-subscription xmlns=\"urn:xmpp:mix:0\">"
+ "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
+ "</update-subscription>"
+ ));
+
+ auto payload = parser.getPayload<MIXUpdateSubscription>();
+ ASSERT_TRUE(payload);
+
+ ASSERT_FALSE(payload->getJID());
+
+ auto items = payload->getSubscriptions();
+ ASSERT_EQ(static_cast<size_t>(1), items.size());
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+}
+
+TEST(MIXUpdateSubscriptionParserTest, XEP0369_Example28_WithJID) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<update-subscription xmlns=\"urn:xmpp:mix:0\" jid=\"hag66@shakespeare.example\">"
+ "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
+ "</update-subscription>"
+ ));
+
+ auto payload = parser.getPayload<MIXUpdateSubscription>();
+ ASSERT_TRUE(payload);
+
+ ASSERT_TRUE(payload->getJID());
+ ASSERT_EQ(JID("hag66@shakespeare.example"), *payload->getJID());
+
+ auto items = payload->getSubscriptions();
+ ASSERT_EQ(static_cast<size_t>(1), items.size());
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+}