Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit ba57f65b authored by Laurent Montel's avatar Laurent Montel 😁

Add more unittest

parent 75ee686c
......@@ -22,6 +22,7 @@
#include "../potentialphishingemailjob.h"
#include <qtest_kde.h>
#include <QStringList>
#include <QSignalSpy>
PotentialPhishingEmailJobTest::PotentialPhishingEmailJobTest(QObject *parent)
: QObject(parent)
......@@ -60,4 +61,22 @@ void PotentialPhishingEmailJobTest::shouldReturnPotentialPhishingEmails()
}
void PotentialPhishingEmailJobTest::shouldEmitSignal()
{
PotentialPhishingEmailJob *job = new PotentialPhishingEmailJob;
QSignalSpy spy(job, SIGNAL(potentialPhisingEmailsFound(QStringList)));
job->setEmails((QStringList() << QLatin1String("\"bla@kde.org\" <foo@kde.org>")));
job->start();
QCOMPARE(spy.count(), 1);
}
void PotentialPhishingEmailJobTest::shouldNotEmitSignalWhenPotentialPhishingNotFound()
{
PotentialPhishingEmailJob *job = new PotentialPhishingEmailJob;
QSignalSpy spy(job, SIGNAL(potentialPhisingEmailsFound(QStringList)));
job->setEmails((QStringList() << QLatin1String("<foo@kde.org>")));
job->start();
QCOMPARE(spy.count(), 0);
}
QTEST_KDEMAIN(PotentialPhishingEmailJobTest, NoGUI)
......@@ -34,6 +34,8 @@ private Q_SLOTS:
void shouldNotStartIfNoEmails();
void shouldReturnPotentialPhishingEmails_data();
void shouldReturnPotentialPhishingEmails();
void shouldEmitSignal();
void shouldNotEmitSignalWhenPotentialPhishingNotFound();
};
#endif // POTENTIALPHISHINGEMAILJOBTEST_H
......@@ -59,8 +59,9 @@ bool PotentialPhishingEmailJob::start()
}
}
}
Q_EMIT potentialPhisingEmailsFound(mPotentialPhisingEmails);
if (!mPotentialPhisingEmails.isEmpty()) {
Q_EMIT potentialPhisingEmailsFound(mPotentialPhisingEmails);
}
deleteLater();
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment