File indexing completed on 2024-12-22 04:46:03

0001 /*
0002    SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "roomutiltest.h"
0008 #include "room/roomutil.h"
0009 #include <QTest>
0010 QTEST_GUILESS_MAIN(RoomUtilTest)
0011 
0012 RoomUtilTest::RoomUtilTest(QObject *parent)
0013     : QObject(parent)
0014 {
0015 }
0016 
0017 void RoomUtilTest::shouldGeneratePermalink()
0018 {
0019     QFETCH(QString, messageId);
0020     QFETCH(QString, roomId);
0021     QFETCH(Room::RoomType, channelType);
0022     QFETCH(QString, generatePermalink);
0023 
0024     QCOMPARE(RoomUtil::generatePermalink(messageId, roomId, channelType), generatePermalink);
0025 }
0026 
0027 void RoomUtilTest::shouldGeneratePermalink_data()
0028 {
0029     QTest::addColumn<QString>("messageId");
0030     QTest::addColumn<QString>("roomId");
0031     QTest::addColumn<Room::RoomType>("channelType");
0032     QTest::addColumn<QString>("generatePermalink");
0033 
0034     QTest::addRow("channels") << QStringLiteral("msId") << QStringLiteral("roomId") << Room::RoomType::Channel << QStringLiteral("channel/roomId?msg=msId");
0035     QTest::addRow("direct") << QStringLiteral("msId") << QStringLiteral("roomId") << Room::RoomType::Direct << QStringLiteral("direct/roomId?msg=msId");
0036     QTest::addRow("group") << QStringLiteral("msId") << QStringLiteral("roomId") << Room::RoomType::Private << QStringLiteral("group/roomId?msg=msId");
0037 }
0038 
0039 #include "moc_roomutiltest.cpp"