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

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 "reactiontest.h"
0008 #include "messages/reaction.h"
0009 
0010 #include <QTest>
0011 QTEST_GUILESS_MAIN(ReactionTest)
0012 
0013 ReactionTest::ReactionTest(QObject *parent)
0014     : QObject(parent)
0015 {
0016 }
0017 
0018 void ReactionTest::shouldHaveDefaultValue()
0019 {
0020     Reaction r;
0021     QVERIFY(r.userNames().isEmpty());
0022     QVERIFY(r.reactionName().isEmpty());
0023     QCOMPARE(r.count(), 0);
0024     QVERIFY(!r.isAnimatedImage());
0025 }
0026 
0027 void ReactionTest::shouldReturnCount()
0028 {
0029     Reaction r;
0030     r.setReactionName(QStringLiteral("bla"));
0031     QCOMPARE(r.reactionName(), QStringLiteral("bla"));
0032     r.setUserNames({QStringLiteral("dd"), QStringLiteral("dd2")});
0033     QCOMPARE(r.count(), 2);
0034 }
0035 
0036 void ReactionTest::shouldShowReactionsToolTip()
0037 {
0038     Reaction r;
0039     r.setReactionName(QStringLiteral(":foo:"));
0040     QCOMPARE(r.convertedUsersNameAtToolTip(), QString());
0041     QStringList userNames;
0042     userNames.append(QStringLiteral("bla"));
0043     r.setUserNames(userNames);
0044     QCOMPARE(r.convertedUsersNameAtToolTip(), QStringLiteral("bla reacted with :foo:"));
0045     userNames.append(QStringLiteral("blo"));
0046     r.setUserNames(userNames);
0047     QCOMPARE(r.convertedUsersNameAtToolTip(), QStringLiteral("bla and blo reacted with :foo:"));
0048     userNames.append(QStringLiteral("bli"));
0049     r.setUserNames(userNames);
0050     QCOMPARE(r.convertedUsersNameAtToolTip(), QStringLiteral("bla, blo and bli reacted with :foo:"));
0051 }
0052 
0053 #include "moc_reactiontest.cpp"