summaryrefslogtreecommitdiffstats
blob: 3e35a82c0b584e04b7c2f704eb712147f8993e43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * 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/Serializer/PayloadSerializers/MIXUpdateSubscriptionSerializer.h>

using namespace Swift;

TEST(MIXUpdateSubscriptionSerializerTest, XEP0369_Example28) {
    MIXUpdateSubscriptionSerializer testling;

    auto update = std::make_shared<MIXUpdateSubscription>();
    update->addSubscription(std::string("urn:xmpp:mix:nodes:messages"));

    std::string expectedResult = "<update-subscription xmlns=\"urn:xmpp:mix:0\">"
                                    "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
                                "</update-subscription>";
    ASSERT_EQ(expectedResult, testling.serialize(update));
}

TEST(MIXUpdateSubscriptionSerializerTest, XEP0369_Example28WithJID) {
    MIXUpdateSubscriptionSerializer testling;

    auto update = std::make_shared<MIXUpdateSubscription>();
    update->setJID(JID("hag66@shakespeare.example"));
    update->addSubscription(std::string("urn:xmpp:mix:nodes:messages"));

    std::string expectedResult = "<update-subscription jid=\"hag66@shakespeare.example\" xmlns=\"urn:xmpp:mix:0\">"
                                    "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
                                "</update-subscription>";
    ASSERT_EQ(expectedResult, testling.serialize(update));
}