File indexing completed on 2025-02-02 04:51:21
0001 /* 0002 SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "changegroupsdescriptionjobtest.h" 0008 #include "groups/changegroupsdescriptionjob.h" 0009 #include "ruqola_restapi_helper.h" 0010 #include <QJsonDocument> 0011 QTEST_GUILESS_MAIN(ChangeGroupsDescriptionJobTest) 0012 using namespace RocketChatRestApi; 0013 ChangeGroupsDescriptionJobTest::ChangeGroupsDescriptionJobTest(QObject *parent) 0014 : QObject(parent) 0015 { 0016 } 0017 0018 void ChangeGroupsDescriptionJobTest::shouldHaveDefaultValue() 0019 { 0020 ChangeGroupsDescriptionJob job; 0021 verifyDefaultValue(&job); 0022 QVERIFY(job.description().isEmpty()); 0023 QVERIFY(!job.hasIdentifier()); 0024 QVERIFY(!job.hasQueryParameterSupport()); 0025 } 0026 0027 void ChangeGroupsDescriptionJobTest::shouldGenerateRequest() 0028 { 0029 ChangeGroupsDescriptionJob job; 0030 QNetworkRequest request = QNetworkRequest(QUrl()); 0031 verifyAuthentication(&job, request); 0032 QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.setDescription"))); 0033 QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); 0034 } 0035 0036 void ChangeGroupsDescriptionJobTest::shouldGenerateJson() 0037 { 0038 ChangeGroupsDescriptionJob job; 0039 const QString roomId = QStringLiteral("foo1"); 0040 const QString description = QStringLiteral("topic1"); 0041 ChannelGroupBaseJob::ChannelGroupInfo info; 0042 info.channelGroupInfoType = ChannelGroupBaseJob::ChannelGroupInfoType::Identifier; 0043 info.identifier = roomId; 0044 job.setChannelGroupInfo(info); 0045 job.setDescription(description); 0046 QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral(R"({"description":"%1","roomId":"%2"})").arg(description, roomId).toLatin1()); 0047 } 0048 0049 #include "moc_changegroupsdescriptionjobtest.cpp"