File indexing completed on 2024-12-01 04:35:25

0001 /*
0002    SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "moderationreportinfotest.h"
0008 #include "moderation/moderationreportinfo.h"
0009 #include "ruqola_autotest_helper.h"
0010 
0011 QTEST_GUILESS_MAIN(ModerationReportInfoTest)
0012 ModerationReportInfoTest::ModerationReportInfoTest(QObject *parent)
0013     : QObject{parent}
0014 {
0015 }
0016 
0017 void ModerationReportInfoTest::shouldHaveDefaultValues()
0018 {
0019     ModerationReportInfo info;
0020     QVERIFY(info.reportIdentifier().isEmpty());
0021     QVERIFY(info.description().isEmpty());
0022     QCOMPARE(info.timeStamp(), -1);
0023     QVERIFY(info.roomId().isEmpty());
0024     QVERIFY(info.userId().isEmpty());
0025     QVERIFY(info.userName().isEmpty());
0026 }
0027 
0028 void ModerationReportInfoTest::shouldLoadReportInfo_data()
0029 {
0030     QTest::addColumn<QString>("name");
0031     QTest::addColumn<ModerationReportInfo>("reportinfo");
0032 
0033     QTest::addRow("empty") << QStringLiteral("empty") << ModerationReportInfo();
0034     ModerationReportInfo moderationReportInfo;
0035     moderationReportInfo.setDescription(QStringLiteral("test report 22222"));
0036     moderationReportInfo.setReportIdentifier(QStringLiteral("65278f64533fd6f8588e"));
0037     moderationReportInfo.setTimeStamp(1697091428125);
0038     moderationReportInfo.setRoomId(QStringLiteral("xxib9aFXMGN3o"));
0039     moderationReportInfo.setUserId(QStringLiteral("H7Q9djXQ4iShzD9T2"));
0040     moderationReportInfo.setUserName(QStringLiteral("bla"));
0041 
0042     QTest::addRow("moderationinfo1") << QStringLiteral("moderationinfo1") << moderationReportInfo;
0043 }
0044 
0045 void ModerationReportInfoTest::shouldLoadReportInfo()
0046 {
0047     QFETCH(QString, name);
0048     QFETCH(ModerationReportInfo, reportinfo);
0049     const QString originalJsonFile = QLatin1String(RUQOLA_DATA_DIR) + QLatin1String("/moderationreportinfo/") + name + QLatin1String(".json");
0050     const QJsonObject obj = AutoTestHelper::loadJsonObject(originalJsonFile);
0051     ModerationReportInfo m;
0052     m.parseModerationReportInfo(obj);
0053     QCOMPARE(m, reportinfo);
0054 }
0055 
0056 #include "moc_moderationreportinfotest.cpp"