Commit 804d0e0e authored by Ahmad Samir's avatar Ahmad Samir Committed by Volker Krause

TemplateParserJob: add unit tests for makeValidHtml method

parent c41b115f
Pipeline #30686 canceled with stage
......@@ -566,4 +566,36 @@ void TemplateParserJobTest::test_processWithTemplatesForContentOtherTimeZone()
QCOMPARE(spy.count(), 1);
}
void TemplateParserJobTest::test_makeValidHtml_data()
{
QTest::addColumn<QString>("message");
QTest::addColumn<QString>("expected");
QTest::newRow("plain text") << QStringLiteral("Some text\n-- \nSignature")
<< QStringLiteral("<html><head></head><body>Some text\n"
"-- \nSignature<br/></body></html>");
QTest::newRow("existing HTML tag") << QStringLiteral("<html><body>Some text\n-- \nSignature</body></html>")
<< QStringLiteral("<html><body>Some text\n-- \nSignature</body></html>");
QTest::newRow("existing body tag, no html") << QStringLiteral("<body>Some text\n-- \nSignature</body>")
<< QStringLiteral("<html><head></head><body>Some text\n"
"-- \nSignature</body></html>");
}
void TemplateParserJobTest::test_makeValidHtml()
{
QFETCH(QString, message);
QFETCH(QString, expected);
KMime::Message::Ptr msg(new KMime::Message);
TemplateParser::TemplateParserJob *parser = new TemplateParser::TemplateParserJob(msg, TemplateParser::TemplateParserJob::Reply);
QString result = message;
parser->makeValidHtml(result);
QCOMPARE(result, expected);
}
QTEST_MAIN(TemplateParserJobTest)
......@@ -49,6 +49,9 @@ private Q_SLOTS:
void test_processWithTemplatesForContentOtherTimeZone();
void test_processWithTemplatesForContentOtherTimeZone_data();
void test_makeValidHtml_data();
void test_makeValidHtml();
};
#endif // TEMPLATEPARSERJOBTEST_H
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