File indexing completed on 2025-02-02 04:51:24

0001 /*
0002    SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "emojicustomdeletejobtest.h"
0008 #include "emoji/emojicustomdeletejob.h"
0009 #include "ruqola_restapi_helper.h"
0010 #include <QJsonDocument>
0011 QTEST_GUILESS_MAIN(EmojiCustomDeleteJobTest)
0012 using namespace RocketChatRestApi;
0013 EmojiCustomDeleteJobTest::EmojiCustomDeleteJobTest(QObject *parent)
0014     : QObject(parent)
0015 {
0016 }
0017 
0018 void EmojiCustomDeleteJobTest::shouldHaveDefaultValue()
0019 {
0020     EmojiCustomDeleteJob job;
0021     verifyDefaultValue(&job);
0022     QVERIFY(job.emojiId().isEmpty());
0023     QVERIFY(!job.hasQueryParameterSupport());
0024 }
0025 
0026 void EmojiCustomDeleteJobTest::shouldGenerateRequest()
0027 {
0028     EmojiCustomDeleteJob job;
0029     QNetworkRequest request = QNetworkRequest(QUrl());
0030     verifyAuthentication(&job, request);
0031     QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/emoji-custom.delete")));
0032     QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json"));
0033 }
0034 
0035 void EmojiCustomDeleteJobTest::shouldGenerateJson()
0036 {
0037     EmojiCustomDeleteJob job;
0038     const QString emojiId = QStringLiteral("foo1");
0039     job.setEmojiId(emojiId);
0040     QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral(R"({"emojiId":"%1"})").arg(emojiId).toLatin1());
0041 }
0042 
0043 #include "moc_emojicustomdeletejobtest.cpp"